name: Build Experimental Docker Image on: pull_request: types: [labeled] workflow_dispatch: inputs: # trunk-ignore(checkov/CKV_GHA_7) branch: description: "Git branch to build" required: true permissions: id-token: write contents: write packages: write actions: write pull-requests: write jobs: build: if: | github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'build-preview') runs-on: ubuntu-latest permissions: id-token: write contents: write packages: write pull-requests: write steps: - name: Run only once per workflow run: echo "Triggered by ${{ github.event_name }}" - name: Checkout code uses: actions/checkout@v4.3.0 with: ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.head_ref }} fetch-depth: 0 - name: PR comment build starting if: github.event_name == 'pull_request' id: build-comment uses: actions/github-script@v7 with: script: | const comment = await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `🔨 Preview build is under way...` }); core.setOutput('comment-id', comment.data.id); - name: Set up QEMU uses: docker/setup-qemu-action@v3.6.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.11.1 - name: Login to Docker Hub uses: docker/login-action@v3.5.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Generate Docker metadata id: meta uses: docker/metadata-action@v5.8.0 with: images: | name=rommapp/romm-testing tags: | type=raw,value=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.head_ref }} - name: Build full image id: build-full uses: docker/build-push-action@v6.18.0 with: file: docker/Dockerfile context: . push: true platforms: linux/arm64,linux/amd64 tags: ${{ steps.meta.outputs.tags }} target: full-image - name: Comment PR with Docker image link if: github.event_name == 'pull_request' uses: actions/github-script@v7 env: HEAD_REF: ${{ github.head_ref }} with: script: | github.rest.issues.updateComment({ comment_id: ${{ steps.build-comment.outputs.comment-id }}, owner: context.repo.owner, repo: context.repo.repo, body: `✅ Preview build completed!\n\nDocker image: \`rommapp/romm-testing:${process.env.HEAD_REF}\`` })