From cd1def516907df46222036d8f484dd62ff8aadc3 Mon Sep 17 00:00:00 2001 From: zu1k Date: Tue, 26 Oct 2021 13:49:14 +0800 Subject: [PATCH] fix: GitHub Actions docker --- .github/workflows/docker.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f6d37f2..2aac3e7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,20 +2,36 @@ name: docker on: [push, pull_request] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: build: name: Build if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Check out code into the Go module directory uses: actions/checkout@v2.3.5 - - - name: Build and push Docker images - uses: docker/build-push-action@v2.7.0 + - name: Log in to the Container registry + uses: docker/login-action@latest with: - username: zu1k + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - registry: docker.pkg.github.com - repository: zu1k/nali/nali - tag_with_ref: true + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@latest + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@2.7.0 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}