diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 9166e2c..40a9137 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,4 +1,5 @@ name: "lint, build and push" +# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/ on: schedule: - cron: "32 17 * * SUN" @@ -6,8 +7,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,12 +40,22 @@ jobs: Status: ${{ job.status }} Source: ${{ github.head_ref }} - build: needs: [gitleaks, hadolint] # shellcheck steps: - - uses: https://github.com/actions/checkout@v4 - - name: Set up Docker Buildx + - name: Checkout code + uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=ref,event=pr + images: | + registry.mgrote.net/httpd + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # - name: Login to Docker Hub # uses: docker/login-action@v3 @@ -59,7 +68,7 @@ jobs: 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 + run: echo $GITHUB_HEAD_REF | tr -cd '[:alnum:]' | sed s/^/REPO_BRANCH=/g >> $GITHUB_OUTPUT id: extract_branch - name: Build and push Docker image uses: https://github.com/docker/build-push-action@v6 @@ -67,7 +76,7 @@ jobs: 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() @@ -83,3 +92,6 @@ jobs: Job: ${{ github.action }} Status: ${{ job.status }} Source: ${{ github.head_ref }} + + +# todosdfs