diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 020e042..50711f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,12 @@ on: push: tags: - '*' - + release: + types: [published] + +permissions: + packages: write + contents: read jobs: build-and-push: runs-on: ubuntu-latest @@ -13,25 +18,24 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to GitHub Container Registry - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Build and Push Docker Image - run: | - LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) - docker buildx create --use - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - -t ghcr.io/${{ github.repository }}:$LATEST_TAG \ - -t ghcr.io/${{ github.repository }}:latest \ - -f Dockerfile . - docker buildx stop ${GITHUB_RUN_ID} - env: - DOCKER_CLI_AGGREGATE: 1 - - - name: Clean up - run: | - docker buildx rm --all + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: | + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}