Check Commit SHA #150
This file contains 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: Check Commit SHA | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
- 'garbage.txt' | |
schedule: | |
# 12:34 AM every day | |
- cron: '34 0 * * *' | |
jobs: | |
get-latest-commit: | |
runs-on: ubuntu-latest | |
outputs: | |
latest-sha: ${{ steps.get-latest-sha.outputs.result }} | |
new-commit: ${{ steps.compare-sha.outputs.NEWCOMMIT }} | |
steps: | |
- name: Get latest commit SHA | |
id: get-latest-sha | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.TOKEN_FOR_ACTIONS }} | |
result-encoding: string | |
script: | | |
const commits = await github.rest.repos.listCommits({ | |
owner: 'docker-library', | |
repo: 'official-images' | |
}); | |
return commits.data[0].sha; | |
- name: Compare SHAs | |
id: compare-sha | |
run: | | |
echo Archived SHA: ${ARCHIVEDSHA} | |
echo Latest SHA: ${LATESTSHA} | |
if [[ $ARCHIVEDSHA == $LATESTSHA ]]; then | |
NEWCOMMIT=false | |
else | |
NEWCOMMIT=true | |
fi | |
echo "NEWCOMMIT=$NEWCOMMIT" >> $GITHUB_OUTPUT | |
echo "NEWCOMMIT=$NEWCOMMIT" | |
env: | |
ARCHIVEDSHA: ${{ vars.DOCKER_LIBRARY_SHA }} | |
LATESTSHA: ${{ steps.get-latest-sha.outputs.result }} | |
trigger-build: | |
if: needs.get-latest-commit.outputs.new-commit == 'true' || startsWith(github.event.head_commit.message, 'FORCE_BUILD=TRUE') | |
needs: get-latest-commit | |
name: Store docker-library commit SHA | |
uses: ./.github/workflows/build.yml | |
secrets: inherit | |