From 66416ae45629d8e70b7eeb6ef74d2cd532e6c845 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa <shion1305@gmail.com> Date: Sun, 2 Feb 2025 21:43:13 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=91=B7=20publish-image.yml=20to=20pub?= =?UTF-8?q?lish=20GHCR=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-image.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/publish-image.yml diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 0000000..e7869e1 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,29 @@ +name: Docker Build Image & publish to GHCR +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build-and-push: + runs-on: ubuntu-24.04-arm + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: docker/Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ github.event_name == 'pull_request' ? 'lumos-discord-bot-dev' : 'lumos-discord-bot' }}:latest From edacd082264abc19df0726bcdc55d3a9bf479c34 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa <shion1305@gmail.com> Date: Sun, 2 Feb 2025 21:59:05 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A7=20Dockerfile=20for=20building?= =?UTF-8?q?=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..d2733b2 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.23-alpine AS builder + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o lumos-discord-bot . + +FROM alpine:latest + +RUN apk add --no-cache ca-certificates + +WORKDIR /app + +COPY --from=builder /app/lumos-discord-bot . + +ENTRYPOINT ["./lumos-discord-bot"] From 68db59c819b0c185df4acb7e6821e634bcc2c6f1 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa <shion1305@gmail.com> Date: Sun, 2 Feb 2025 22:07:12 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=90=9B=20expression=20error=20in=20ta?= =?UTF-8?q?gs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index e7869e1..d716149 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -6,6 +6,8 @@ on: pull_request: branches: - main + paths: + - '.github/workflows/publish-image.yml' jobs: build-and-push: runs-on: ubuntu-24.04-arm @@ -26,4 +28,4 @@ jobs: context: . file: docker/Dockerfile push: true - tags: ghcr.io/${{ github.repository_owner }}/${{ github.event_name == 'pull_request' ? 'lumos-discord-bot-dev' : 'lumos-discord-bot' }}:latest + tags: "ghcr.io/${{ github.repository_owner }}/lumos-discord-bot:latest" From 1ff15c3de53b934b97f98beea66b28dc3147cfe1 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa <shion1305@gmail.com> Date: Sun, 2 Feb 2025 22:08:15 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20upgrade=20actions=20ve?= =?UTF-8?q?rsion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index d716149..970b74a 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -16,14 +16,14 @@ jobs: uses: actions/checkout@v4 - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . file: docker/Dockerfile From a415c919531b4c983cee860a03f5215551089953 Mon Sep 17 00:00:00 2001 From: Shion Ichikawa <shion1305@gmail.com> Date: Sun, 2 Feb 2025 22:12:33 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B=20lowercase=20ghcr=20repo=20sl?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-image.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 970b74a..ca8e41b 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -22,10 +22,17 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Format repo slug + uses: actions/github-script@v4 + id: repo_slug + with: + result-encoding: string + script: return `ghcr.io/${github.repository.toLowerCase()}` + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: docker/Dockerfile push: true - tags: "ghcr.io/${{ github.repository_owner }}/lumos-discord-bot:latest" + tags: "ghcr.io/lumos-programming/lumos-discord-bot:latest"