name: Build Images # Only images whose files changed get built. A release is cut by pushing a tag # named /vX.Y.Z, which publishes that one image. on: push: branches: [main] tags: ["*/v*"] pull_request: branches: [main] workflow_dispatch: inputs: image: description: Image to build, or "all" default: all required: true concurrency: group: build-${{ github.ref }} cancel-in-progress: true env: REGISTRY: gitea.libretechconsulting.com NAMESPACE: rmcguire DOCKER_USER: rmcguire jobs: select: name: Select images runs-on: ubuntu-latest outputs: images: ${{ steps.select.outputs.images }} any: ${{ steps.select.outputs.any }} steps: - name: Check out repository uses: actions/checkout@v7 with: fetch-depth: 0 # need history to diff against the base commit - name: Work out which images changed id: select run: ./hack/select-images.sh >> "$GITHUB_OUTPUT" env: DISPATCH_IMAGE: ${{ github.event.inputs.image }} BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} # One job that loops, rather than a matrix job per image: Gitea resolves a matrix # when it parses the workflow, before `needs` outputs exist, so a dynamic matrix # produces a single job named after the raw expression. Looping keeps the job name # readable and gives one collapsible log section per image. build: name: Build changed images needs: select if: needs.select.outputs.any == 'true' runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v7 # Never on a pull request, which is exactly when nothing gets published. - name: Log in to the Gitea container registry if: github.event_name != 'pull_request' uses: docker/login-action@v4 with: registry: ${{ env.REGISTRY }} username: ${{ env.DOCKER_USER }} password: ${{ secrets.API_TOKEN }} - name: Build, smoke-test and publish run: ./hack/build-images.sh ${{ needs.select.outputs.images }} env: PR_NUMBER: ${{ github.event.pull_request.number }}