Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build container (PR)
on:
pull_request:

permissions:
contents: read

concurrency:
group: build-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
matrix:
name: Generate build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v6

- name: Generate matrix from matrix.json
id: generate
run: |
DEFAULT_JDK=$(jq -r '.default_jdk' matrix.json)
MATRIX=$(jq -c --arg default "$DEFAULT_JDK" '{
"include": [.java_versions[] | {
"java_version": .,
"is_default_jdk": (. == $default)
}]
}' matrix.json)
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT

build:
name: Build JDK ${{ matrix.java_version }}
needs: matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v6

- name: Extract versions from Dockerfile
id: versions
run: |
set -euo pipefail
RUNNER_TAG=$(grep -m1 '^ARG VERSION=' Dockerfile | cut -d= -f2)

if [ -z "$RUNNER_TAG" ]; then
echo "::error::Failed to extract versions from Dockerfile"
exit 1
fi

echo "runner_tag=${RUNNER_TAG}" >> $GITHUB_OUTPUT
Comment thread
compscidr marked this conversation as resolved.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Build (no push)
uses: docker/build-push-action@v7
with:
context: .
push: false
build-args: |
VERSION=${{ steps.versions.outputs.runner_tag }}
JAVA_VERSION=${{ matrix.java_version }}

gate:
name: All builds passed
needs: [matrix, build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check that all required jobs succeeded
run: |
if [ "${{ needs.matrix.result }}" != "success" ] || [ "${{ needs.build.result }}" != "success" ]; then
echo "::error::A required job failed or was cancelled (matrix: ${{ needs.matrix.result }}, build: ${{ needs.build.result }})"
exit 1
fi
echo "All builds succeeded"
25 changes: 22 additions & 3 deletions .github/workflows/check-sdk-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,30 @@ on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write
contents: read

jobs:
check-updates:
name: Check for updates
runs-on: ubuntu-latest
steps:
- name: Verify AUTOMERGE_PAT is configured
env:
AUTOMERGE_PAT: ${{ secrets.AUTOMERGE_PAT }}
run: |
if [ -z "$AUTOMERGE_PAT" ]; then
echo "::error::AUTOMERGE_PAT secret is not configured. Create a fine-grained PAT scoped to this repo with contents:write and pull-requests:write, and save it as a repository secret named AUTOMERGE_PAT. PRs created with the default GITHUB_TOKEN never trigger the build workflow, so they could never auto-merge."
exit 1
fi

if ! GH_TOKEN="$AUTOMERGE_PAT" gh api user --silent; then
echo "::error::AUTOMERGE_PAT is invalid or expired. Generate a new fine-grained PAT (contents: write, pull-requests: write, this repo only) and update the AUTOMERGE_PAT repository secret."
exit 1
fi

- uses: actions/checkout@v6
with:
token: ${{ secrets.AUTOMERGE_PAT }}

- name: Check for new JDK versions
id: jdk
Expand Down Expand Up @@ -177,7 +192,7 @@ jobs:
- name: Create pull request
if: steps.jdk.outputs.has_new == 'true' || steps.sdk.outputs.updated == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.AUTOMERGE_PAT }}
run: |
BRANCH="automated/sdk-jdk-updates"

Expand Down Expand Up @@ -236,3 +251,7 @@ jobs:
else
echo "PR #${EXISTING} already exists, updated with force push"
fi

# Enable auto-merge so the PR merges once "All builds passed" succeeds.
# Runs for both new and force-updated existing PRs; idempotent.
gh pr merge --auto --merge "$BRANCH"
Loading