-
Notifications
You must be signed in to change notification settings - Fork 26
82 lines (72 loc) · 2.95 KB
/
update-timestamps.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
74
75
76
77
78
79
80
81
82
name: Check for new Release Train snapshots
on:
workflow_dispatch:
pull_request: #temporary
schedule:
- cron: '0 7 * * *' # Run at 7am on default branch
jobs:
upstream_check:
outputs:
timestamps_changed: "{{ steps.timestamp_check.outputs.timestamps_changed }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check for updated Ark timestamps and replace in defaults.yml
run: |
dev/setup-env.sh
. venv/bin/activate
. environments/.stackhpc/activate
git checkout auto/bump-timestamps || git checkout -b auto/bump-timestamps
ansible-playbook ansible/ci/update_timestamps.yml -v
- name: Check if timestamps were changed
id: timestamp_check
run: |
set +e
git diff --quiet
echo "timestamps_changed=$?" >> "$GITHUB_OUTPUT"
# TODO: find way to stop CI running if pushing to existing PR
- name: Push new timestamps
if: "${{ steps.timestamp_check.outputs.timestamps_changed }} == 0"
run: |
git add environments/common/inventory/group_vars/all/defaults.yml
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "Bumped repo timestamps"
git config --global --add --bool push.autoSetupRemote true
git push
build_fatimage:
if: "${{ needs.upstream_check.outputs.timestamps_changed }} == 0"
needs: upstream_check
uses: ./.github/workflows/fatimage.yml
with:
ci_cloud: LEAFCLOUD
branch: auto/bump-timestamps
ci_and_pr:
if: "${{ needs.upstream_check.outputs.timestamps_changed }} == 0"
needs:
- upstream_check
- build_fatimage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Bump CI with new images
run: |
git checkout auto/bump-timestamps
sed -i 's/"RL8".*$/"RL8": "${{ needs.build_fatimage.outputs.openhpc-RL8-image }}"/' environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
sed -i 's/"RL9".*$/"RL9": "${{ needs.build_fatimage.outputs.openhpc-RL9-image }}"/' environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
- name: Push new images
run: |
git add environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "Bumped images"
git push
- name: Check if PR exists
id: pr-check
run: |
set +e
gh pr list --json headRefName --jq '.[].headRefName' | grep auto/bump-timestamps
echo "pr_exists=$?" >> "$GITHUB_OUTPUT"
- name: Create PR
if: ${{ steps.pr-check.outputs.pr_exists }}
run: gh pr create --title "[Auto] Bump repo timestamps to latest" --base main --head auto/bump-timestamps