-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (51 loc) · 1.61 KB
/
check-sha.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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