From d8d0af5a1452def236e9933f4eceb306d99820d1 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Sun, 13 Oct 2024 19:57:47 +0200 Subject: [PATCH] ci: new tag format on pr (#45) Reviewed-on: https://git.mgrote.net///container-images/httpd/pulls/45 Co-authored-by: Michael Grote Co-committed-by: Michael Grote --- .gitea/workflows/build.yaml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 9166e2c..a51251f 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,4 +1,6 @@ name: "lint, build and push" +# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/ +# Variables: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables + https://forgejo.org/docs/latest/user/actions/#env-1 on: schedule: - cron: "32 17 * * SUN" @@ -6,8 +8,6 @@ on: branches: [ master ] pull_request: -# Variables: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables + https://forgejo.org/docs/latest/user/actions/#env-1 - jobs: lint: steps: @@ -41,11 +41,21 @@ jobs: Status: ${{ job.status }} Source: ${{ github.head_ref }} - build: needs: [gitleaks, hadolint] # shellcheck steps: - - uses: https://github.com/actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Extract repository name + id: name + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + registry.mgrote.net/${{ steps.name.outputs.REPO_NAME }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # - name: Login to Docker Hub @@ -53,21 +63,13 @@ jobs: # with: # username: ${{ secrets.DOCKERHUB_USERNAME }} # password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Extract repository name - id: meta - run: | - echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT - - name: Extract branch name - shell: bash - run: echo "REPO_BRANCH=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - id: extract_branch - name: Build and push Docker image uses: https://github.com/docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true - tags: "registry.mgrote.net/${{ steps.meta.outputs.REPO_NAME }}:latest,registry.mgrote.net/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.extract_branch.outputs.REPO_BRANCH }}" + tags: ${{ steps.meta.outputs.tags }} - name: Send notification uses: dawidd6/action-send-mail@v3 if: failure()