Fix Tag Generation for UBI 10 #61
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Official Images Updates | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "master" | |
| - "8" | |
| - "7" | |
| - "6" | |
| pull_request: | |
| permissions: {} | |
| jobs: | |
| library-gradle: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # we need all branches so we can read Dockerfiles from them | |
| - name: Provision best available generate-stackbrew-library.sh and toolbox | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| CURRENT_COMMIT: ${{ github.sha }} | |
| BASE_REF: ${{ github.event.pull_request.base.ref }} | |
| shell: bash | |
| run: | | |
| # if the generate-stackbrew-library.sh was modified in the current PR, use that version; otherwise, use the version from master | |
| if [ "${EVENT_NAME}" == "pull_request" ] && [ "$(git diff --name-only "origin/$BASE_REF..$CURRENT_COMMIT" -- 'generate-stackbrew-library.sh' | wc -l)" -gt 0 ]; then | |
| echo "Using modified generate-stackbrew-library.sh" | |
| else | |
| echo "Using generate-stackbrew-library.sh from master branch" | |
| git checkout origin/master -- generate-stackbrew-library.sh | |
| fi | |
| # if the toolbox Dockerfile was modified in the current PR, use that version; otherwise, use the version from master | |
| if [ "${EVENT_NAME}" == "pull_request" ] && [ "$(git diff --name-only "origin/$BASE_REF..$CURRENT_COMMIT" -- 'toolbox/Dockerfile' | wc -l)" -gt 0 ]; then | |
| echo "Using modified toolbox/Dockerfile" | |
| else | |
| echo "Using toolbox/Dockerfile from master branch" | |
| git checkout origin/master -- toolbox/Dockerfile | |
| fi | |
| - run: docker build --tag gradle-dockerhub-toolbox -f toolbox/Dockerfile toolbox | |
| - name: Generate library file | |
| run: | | |
| docker run --rm \ | |
| -v "$PWD:/workspace" \ | |
| -w /workspace \ | |
| -e CURRENT_COMMIT \ | |
| -e BASE_SHA \ | |
| gradle-dockerhub-toolbox \ | |
| bash -c "./generate-stackbrew-library.sh ${BASE_SHA:+'--substitute' '${BASE_SHA}' '${CURRENT_COMMIT}'} > library-gradle" | |
| env: | |
| CURRENT_COMMIT: ${{ github.sha }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| - name: Archive library file | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle | |
| path: library-gradle | |
| - name: Compare library files | |
| id: compare | |
| run: | | |
| curl -q -sS -o /dev/stdout "https://raw.githubusercontent.com/docker-library/official-images/refs/heads/master/library/gradle" | \ | |
| sed -E "s/GitCommit: .*/GitCommit: 0000000000000000000000000000000000000000/" > existing-library-gradle | |
| sed -E "1d; s/GitCommit: .*/GitCommit: 0000000000000000000000000000000000000000/" library-gradle > updated-library-gradle | |
| DIFF_OUTPUT=$(diff --color=always existing-library-gradle updated-library-gradle || :) | |
| echo "$DIFF_OUTPUT" | |
| echo "diff<<EOF" >> $GITHUB_OUTPUT | |
| echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Comment PR with diff | |
| if: github.event_name == 'pull_request' && steps.compare.outputs.diff != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const diff = `${{ steps.compare.outputs.diff }}`; | |
| const body = `<details> | |
| <summary>Library file diff (ignoring commit id's)</summary> | |
| \`\`\`diff | |
| ${diff} | |
| \`\`\` | |
| </details>`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body | |
| }); |