-
Notifications
You must be signed in to change notification settings - Fork 16
73 lines (65 loc) · 2.65 KB
/
check_versions.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
name: Check container software versions
on:
workflow_dispatch:
# Check for new versions in adsbx repos
schedule:
- cron: "0 12 * * *"
env:
GHCR_IMAGE: ${{ github.repository }}:latest
GHCR_REGISTRY: ghcr.io
WORKFLOW_FILE_TO_TRIGGER: deploy.yml
WORKFLOW_AUTH_TOKEN: ${{ secrets.GH_PAT_MIKENYE }}
jobs:
version_in_container:
name: Check versions in 'latest' image
runs-on: ubuntu-latest
outputs:
currverhash: ${{ steps.current-version.outputs.currverhash }}
steps:
- name: Get versions from ${{ env.GHCR_IMAGE }}
id: current-version
run: |
set -x
docker run --rm --entrypoint cat ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE }} /VERSIONS
echo "::set-output name=currverhash::$(docker run --rm --entrypoint md5sum ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE }} /VERSIONS)"
latest_version:
name: Check latest versions
runs-on: ubuntu-latest
outputs:
latestverhash: ${{ steps.latest-version.outputs.latestverhash }}
steps:
- name: Build image
uses: docker/build-push-action@v4
with:
push: false
load: true
tags: local_image_for_versions:latest
- name: Get versions from newly built image
id: latest-version
run: |
set -x
docker run --rm --entrypoint cat local_image_for_versions /VERSIONS
echo "::set-output name=latestverhash::$(docker run --rm --entrypoint md5sum local_image_for_versions /VERSIONS)"
display_versions:
name: Display versions
needs: [version_in_container, latest_version]
runs-on: ubuntu-latest
steps:
- name: Display versions
run: |
echo "version hash in current latest image = ${{ needs.version_in_container.outputs.currverhash }}"
echo "version hash in image just built = ${{ needs.latest_version.outputs.latestverhash }}"
echo "will a deployment be triggered = ${{ needs.version_in_container.outputs.currverhash != needs.latest_version.outputs.latestverhash }}"
trigger_deploy:
name: Trigger deployment of image
needs: [version_in_container, latest_version]
if: ${{ needs.version_in_container.outputs.currverhash != needs.latest_version.outputs.latestverhash }}
runs-on: ubuntu-latest
env:
WORKFLOW_REASON: "triggered via check_versions.yml in ${{ github.repository }}"
steps:
- name: Trigger ${{ env.WORKFLOW_FILE }} in ${{ env.WORKFLOW_REPO }}
run: |
echo "$WORKFLOW_AUTH_TOKEN" | gh auth login --with-token
gh workflow run --ref main --repo "${{ github.repository }}" "${{ env.WORKFLOW_FILE_TO_TRIGGER }}" -f reason="$WORKFLOW_REASON"