From 4dad1315d8de9c29a3264e5eb814b47c15ef2c1e Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 26 Nov 2024 23:18:44 +0800 Subject: [PATCH] workflow: push docker image to ghcr.io --- .github/workflows/docker.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 90ff7613..65db4f29 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,6 +8,9 @@ on: jobs: build: runs-on: ubuntu-22.04 + permissions: + packages: write + contents: read steps: - uses: actions/checkout@v4 - name: Install packages @@ -28,6 +31,11 @@ jobs: with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Determine docker tags id: docker_tag run: | @@ -42,18 +50,22 @@ jobs: echo "ALPINE_TAG=tsl0922/ttyd:alpine" >> $GITHUB_ENV esac - name: build/push docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x push: true - tags: ${{ env.DOCKER_TAG }} + tags: | + ${{ env.DOCKER_TAG }} + ghcr.io/${{ env.DOCKER_TAG }} - name: build/push docker image (alpine) - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile.alpine platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x push: true - tags: ${{ env.ALPINE_TAG }} + tags: | + ${{ env.ALPINE_TAG }} + ghcr.io/${{ env.ALPINE_TAG }}