@@ -17,38 +17,43 @@ jobs:
1717 runs-on : ubuntu-latest
1818 permissions :
1919 contents : read
20+ pull-requests : write
2021 steps :
2122 - name : Checkout
2223 uses : actions/checkout@v5
2324 with :
2425 fetch-depth : 0 # we need all branches so we can read Dockerfiles from them
25- - name : Provision best available generate-stackbrew-library.sh
26+ - name : Provision best available generate-stackbrew-library.sh and toolbox
2627 env :
2728 EVENT_NAME : ${{ github.event_name }}
2829 CURRENT_COMMIT : ${{ github.sha }}
2930 BASE_REF : ${{ github.event.pull_request.base.ref }}
30- # if the script was modified in the current PR, use that version; otherwise, use the version from master
3131 shell : bash
3232 run : |
33+ # if the generate-stackbrew-library.sh was modified in the current PR, use that version; otherwise, use the version from master
3334 if [ "${EVENT_NAME}" == "pull_request" ] && [ "$(git diff --name-only "origin/$BASE_REF..$CURRENT_COMMIT" -- 'generate-stackbrew-library.sh' | wc -l)" -gt 0 ]; then
3435 echo "Using modified generate-stackbrew-library.sh"
3536 else
3637 echo "Using generate-stackbrew-library.sh from master branch"
3738 git checkout origin/master -- generate-stackbrew-library.sh
3839 fi
40+ # if the toolbox Dockerfile was modified in the current PR, use that version; otherwise, use the version from master
41+ if [ "${EVENT_NAME}" == "pull_request" ] && [ "$(git diff --name-only "origin/$BASE_REF..$CURRENT_COMMIT" -- 'toolbox/Dockerfile' | wc -l)" -gt 0 ]; then
42+ echo "Using modified toolbox/Dockerfile"
43+ else
44+ echo "Using toolbox/Dockerfile from master branch"
45+ git checkout origin/master -- toolbox/Dockerfile
46+ fi
47+ - run : docker build --tag gradle-dockerhub-toolbox -f toolbox/Dockerfile toolbox
3948 - name : Generate library file
40- uses : docker://bash:latest
41- with :
42- # See https://github.com/docker-library/bashbrew?tab=readme-ov-file#installing
43- args : |
44- -c "\
45- apk add --no-cache jq git curl ca-certificates && \
46- git config --global --add safe.directory '*' && \
47- curl -fsSL -o /usr/local/bin/bashbrew https://github.com/docker-library/bashbrew/releases/download/v0.1.13/bashbrew-amd64 && \
48- chmod +x /usr/local/bin/bashbrew && \
49- bashbrew --version && \
50- ./generate-stackbrew-library.sh ${BASE_SHA:+--substitute ${BASE_SHA} ${CURRENT_COMMIT}} > library-gradle \
51- "
49+ run : |
50+ docker run --rm \
51+ -v "$PWD:/ws" \
52+ -w /ws \
53+ -e CURRENT_COMMIT \
54+ -e BASE_SHA \
55+ gradle-dockerhub-toolbox \
56+ bash -c 'if [ -n "$BASE_SHA" ]; then ./generate-stackbrew-library.sh --substitute "$BASE_SHA" "$CURRENT_COMMIT"; else ./generate-stackbrew-library.sh; fi > library-gradle'
5257 env :
5358 CURRENT_COMMIT : ${{ github.sha }}
5459 BASE_SHA : ${{ github.event.pull_request.base.sha }}
5762 with :
5863 name : gradle
5964 path : library-gradle
65+ - name : Compare library files
66+ id : compare
67+ run : |
68+ curl -q -sS -o /dev/stdout "https://raw.githubusercontent.com/docker-library/official-images/refs/heads/master/library/gradle" | \
69+ sed -E "s/GitCommit: .*/GitCommit: 0000000000000000000000000000000000000000/" > existing-library-gradle
70+ sed -E "1d; s/GitCommit: .*/GitCommit: 0000000000000000000000000000000000000000/" library-gradle > updated-library-gradle
71+ DIFF_OUTPUT=$(diff existing-library-gradle updated-library-gradle || :)
72+ echo "$DIFF_OUTPUT"
73+ echo "diff<<EOF" >> $GITHUB_OUTPUT
74+ echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT
75+ echo "EOF" >> $GITHUB_OUTPUT
76+ - name : Comment PR with diff
77+ if : github.event_name == 'pull_request' && steps.compare.outputs.diff != ''
78+ uses : actions/github-script@v7
79+ with :
80+ script : |
81+ const diff = `${{ steps.compare.outputs.diff }}`;
82+ const body = `<details>
83+ <summary>Library file diff (ignoring commit IDs)</summary>
84+
85+ \`\`\`diff
86+ ${diff}
87+ \`\`\`
88+
89+ </details>`;
90+
91+ github.rest.issues.createComment({
92+ issue_number: context.issue.number,
93+ owner: context.repo.owner,
94+ repo: context.repo.repo,
95+ body: body
96+ });
0 commit comments