name: Push PR Image on Label on: pull_request: branches: - master types: [ labeled ] paths: - '!.markdownlint.yaml' - '!.vale.ini' - '!deployments/kubernetes/chart/reloader/**' env: DOCKER_FILE_PATH: Dockerfile REGISTRY: ghcr.io # Default to no GITHUB_TOKEN permissions; each job opts into the minimum it needs. permissions: {} jobs: build-and-push-pr-image: permissions: contents: read runs-on: ubuntu-latest name: Build and Push PR Image if: ${{ github.event.label.name == 'build-and-push-pr-image' }} steps: - name: Check out code uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: ref: ${{github.event.pull_request.head.sha}} fetch-depth: 0 - name: Set up Go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version-file: 'go.mod' check-latest: true cache: false - name: Install Dependencies run: | make install - name: Run golangci-lint run: make lint - name: Generate Tags id: generate_tag run: | sha=${{ github.event.pull_request.head.sha }} tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}" echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 - name: Generate image repository path for ghcr registry run: | echo GHCR_IMAGE_REPOSITORY=${{env.REGISTRY}}/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Login to ghcr registry uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 with: registry: ${{env.REGISTRY}} username: stakater-user password: ${{secrets.GITHUB_TOKEN}} - name: Build Docker Image uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 with: context: . file: ${{ env.DOCKER_FILE_PATH }} pull: true push: true build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }} platforms: linux/amd64,linux/arm,linux/arm64 tags: | ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }} labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} org.opencontainers.image.created=${{ steps.prep.outputs.created }} org.opencontainers.image.revision=${{ github.sha }}