diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 5b7bcd0..c87d0e5 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -1,84 +1,73 @@ -name: Build - -on: - push: - branches: - - main - - pull_request: - branches: [ "**" ] - -env: - SHA: ${{ github.event.pull_request.head.sha || github.event.after }} - COMPARE_TAG: latest - -jobs: - build: - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} - runs-on: ubuntu-latest - name: Build - container: - image: catthehacker/ubuntu:act-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get Meta - id: repometa - run: | - echo REGISTRY_DOMAIN=$(echo ${GITHUB_SERVER_URL} | sed 's\^https://\\') >> $GITHUB_OUTPUT - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker BuildX - uses: docker/setup-buildx-action@v3 - - - name: Login to registry - uses: docker/login-action@v3 - with: - registry: ${{ steps.repometa.outputs.REGISTRY_DOMAIN }} - username: ${{ github.repository_owner }} - password: ${{ secrets.CI_REGISTRY_TOKEN }} - - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.repometa.outputs.REGISTRY_DOMAIN }}/${{ github.repository }} - labels: | - org.opencontainers.image.revision=${{ env.SHA }} - tags: | - type=edge,branch=$repo.default_branch - type=sha,prefix=,suffix=,format=short - type=raw,value=latest,enable={{is_default_branch}} - - - name: Build and push - uses: docker/build-push-action@v5 - env: - ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119 - with: - context: . - file: ./Dockerfile - platforms: | - linux/amd64 - linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - -# - name: Docker Scout -# id: docker-scout -# if: ${{ github.event_name == 'pull_request' }} -# uses: docker/scout-action@v0.23.4 -# with: -# dockerhub-user: ${{ secrets.DOCKERHUB_USER }} -# dockerhub-password: ${{ secrets.DOCKERHUB_PASSWORD }} -# command: compare -# # image: ${{ steps.meta.outputs.tags }} -# to: ${{ steps.repometa.outputs.REGISTRY_DOMAIN }}/${{ github.repository }}:${{ env.COMPARE_TAG }} -# ignore-unchanged: true -# write-comment: true -# github-token: ${{ secrets.GITHUB_TOKEN }} # to be able to write the comment +name: Build + +on: + push: + branches: + - main + + pull_request: + branches: [ "**" ] + + workflow_dispatch: + +env: + SHA: ${{ github.event.pull_request.head.sha || github.event.after }} + +jobs: + build: + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + runs-on: ubuntu-latest + name: Docker image + + container: + image: catthehacker/ubuntu:act-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get Meta + id: repometa + run: | + echo REGISTRY_DOMAIN=$(echo ${GITHUB_SERVER_URL} | sed 's\^https://\\') >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v3 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.repometa.outputs.REGISTRY_DOMAIN }} + username: ${{ github.repository_owner }} + password: ${{ secrets.CI_REGISTRY_TOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.repometa.outputs.REGISTRY_DOMAIN }}/${{ github.repository }} + labels: | + org.opencontainers.image.revision=${{ env.SHA }} + tags: | + type=edge,branch=$repo.default_branch + type=sha,prefix=,suffix=,format=short + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v5 + env: + ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119 + with: + context: . + file: ./Dockerfile + platforms: | + linux/amd64 + linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max