fixing github action
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
name: Build Hugo
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ vars.DOCKERHUB_USERNAME }}/blog-ahmza-com:latest
|
||||
${{ vars.DOCKERHUB_USERNAME }}/blog-ahmza-com:1.0.0
|
||||
ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:latest
|
||||
ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:1.0.0
|
||||
Regular → Executable
+10
-31
@@ -1,32 +1,11 @@
|
||||
FROM golang:1.22.5-alpine AS build
|
||||
ARG GITLAB_TOKEN
|
||||
FROM ghcr.io/hugomods/hugo:0.128.2 AS build
|
||||
ARG GH_ACCESS_TOKEN
|
||||
WORKDIR /tmp/hugo
|
||||
COPY . .
|
||||
RUN apk add --no-cache make && git config --global url.https://${GH_ACCESS_TOKEN}@github.com/.insteadOf https://github.com/ && make build
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# install curl and git
|
||||
RUN apk add --update curl git
|
||||
|
||||
# download and unnzip the hugo binary
|
||||
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.128.2/hugo_0.128.2_linux-${TARGETARCH}.tar.gz > hugo.tar.gz && tar -zxf hugo.tar.gz && mv hugo /usr/local/bin
|
||||
|
||||
# clone the blog repository
|
||||
RUN git clone https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
|
||||
|
||||
# set blog (folder we just cloned) as the current DIR
|
||||
WORKDIR blog
|
||||
|
||||
# run hugo --minify to generate static files
|
||||
RUN hugo --minify --gc
|
||||
|
||||
|
||||
# Nginx image is as basic as we can get without introducing further complexity
|
||||
FROM nginx
|
||||
|
||||
# copy the nginx.conf file
|
||||
COPY --from=build /go/blog/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# copy the static files
|
||||
COPY --from=build /go/blog/public/ /usr/share/nginx/html
|
||||
|
||||
# Tell the image to expose port 80 for HTTP, SSL provided by reverse proxy.
|
||||
EXPOSE 80
|
||||
FROM nginx:alpine-slim
|
||||
WORKDIR /usr/share/nginx/html
|
||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build /tmp/hugo/public .
|
||||
EXPOSE 80/tcp
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
FROM golang:1.22.5-alpine AS build
|
||||
ARG GITLAB_TOKEN
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# install curl and git
|
||||
RUN apk add --update curl git
|
||||
|
||||
# download and unnzip the hugo binary
|
||||
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.128.2/hugo_0.128.2_linux-${TARGETARCH}.tar.gz > hugo.tar.gz && tar -zxf hugo.tar.gz && mv hugo /usr/local/bin
|
||||
|
||||
# clone the blog repository
|
||||
RUN git clone https://oauth2:$GITLAB_TOKEN@gitlab.com/AHMZA/blog.git
|
||||
|
||||
# set blog (folder we just cloned) as the current DIR
|
||||
WORKDIR blog
|
||||
|
||||
# run hugo --minify to generate static files
|
||||
RUN hugo --minify --gc
|
||||
|
||||
|
||||
# Nginx image is as basic as we can get without introducing further complexity
|
||||
FROM nginx
|
||||
|
||||
# copy the nginx.conf file
|
||||
COPY --from=build /go/blog/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# copy the static files
|
||||
COPY --from=build /go/blog/public/ /usr/share/nginx/html
|
||||
|
||||
# Tell the image to expose port 80 for HTTP, SSL provided by reverse proxy.
|
||||
EXPOSE 80
|
||||
Reference in New Issue
Block a user