From b9cf9cd94fe212b801672ce2ee86d96c096ceb79 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 29 Jan 2023 15:29:59 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20.github:=20use=20docker's?= =?UTF-8?q?=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-image.yml | 47 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 4ba7fc8..06311b2 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -4,7 +4,6 @@ on: [push, workflow_dispatch] env: ENDPOINT: "neingeist/docker-mod-terminfos" - BRANCH: "master" jobs: build: @@ -12,34 +11,34 @@ jobs: permissions: packages: write steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Docker meta + - + name: Docker - Meta id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/neingeist/docker-mod-terminfos + images: ghcr.io/{{ ENDPOINT }} tags: | type=ref,event=branch # set latest tag for default branch type=raw,value=latest,enable={{is_default_branch}} - - - name: Build image - run: | - docker build --no-cache -t ${{ github.sha }} . - - name: Tag image - if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} - run: | - docker tag ${{ github.sha }} ${ENDPOINT} - docker tag ${{ github.sha }} ${ENDPOINT}:${{ github.sha }} - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT} - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${{ github.sha }} - - name: Login to GitHub Container Registry - if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push tags to GitHub Container Registry - if: ${{ github.ref == format('refs/heads/{0}', env.BRANCH) && env.ENDPOINT != 'user/endpoint' }} - run: | - docker push ghcr.io/${ENDPOINT}:${{ github.sha }} - docker push ghcr.io/${ENDPOINT} + - + name: Docker - Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Docker - Login to GitHub Container Registry + if: github.ref_type == 'branch' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN } + - + name: Docker - Build and push + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_type == 'branch' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}