name: Build and Push Container on: push: branches: - main tags: - v* workflow_dispatch: null pull_request: branches: - main env: REGISTRY: gitea.wayfinderak.com IMAGE_NAME: wayfinderak/prepbot concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: docker: runs-on: butler-ci steps: - name: Checkout uses: actions/checkout@v4 - name: Select relevant delivery work id: delivery env: DELIVERY_EVENT: ${{ github.event_name }} DELIVERY_REF: ${{ github.ref }} DELIVERY_SHA: ${{ github.sha }} DELIVERY_BASE: ${{ github.event.pull_request.base.sha || github.event.before }} run: | cd . bash scripts/ci-select.sh - name: Set up QEMU if: ${{ steps.delivery.outputs.run == 'true' }} uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx if: ${{ steps.delivery.outputs.run == 'true' }} uses: docker/setup-buildx-action@v3 - name: Log in to Gitea registry if: ${{ (steps.delivery.outputs.run == 'true') && github.event_name != 'pull_request' }} uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Prepare image tags if: ${{ steps.delivery.outputs.run == 'true' }} id: prep shell: bash run: | short_sha="${GITHUB_SHA::7}" tags="${REGISTRY}/${IMAGE_NAME}:sha-${short_sha}" tags+=$'\n'"${REGISTRY}/${IMAGE_NAME}:sha-${GITHUB_SHA}" if [[ "${GITHUB_REF_TYPE}" == "branch" && ("${GITHUB_REF_NAME}" == "master" || "${GITHUB_REF_NAME}" == "main") ]]; then tags+=$'\n'"${REGISTRY}/${IMAGE_NAME}:latest" fi if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then version="${GITHUB_REF_NAME#v}" tags+=$'\n'"${REGISTRY}/${IMAGE_NAME}:${version}" fi { echo 'tags<> "$GITHUB_OUTPUT" - name: Build and push image if: ${{ steps.delivery.outputs.run == 'true' }} uses: docker/build-push-action@v6 with: context: . push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.prep.outputs.tags }} labels: org.opencontainers.image.revision=${{ github.sha }}