@@ -15,14 +15,60 @@ jobs:
1515 . venv/bin/activate
1616 . environments/.stackhpc/activate
1717
18+ - name : Switch to automation branch
19+ run : git checkout -b auto/bump-timestamps || git checkout auto/bump-timestamps
20+
1821 - name : Check for updated Ark timestamps and replace in defaults.yml
1922 run : ansible-playbook ansible/ci/update_timestamps.yml
2023
21- - name : Create Pull Request
22- uses : peter-evans/create-pull-request@v7
23- with :
24- add-paths : environments/common/inventory/group_vars/all/defaults.yml
25- commit-message : " [automated] bumped repo timestamps to latest"
26- branch : auto/bump-timestamps
27- title : " [Automation] Bumped repo timestamps to latest"
28- body : Automated changes by .github/workflows/update-timestamps.yml
24+ - name : Check if timestamps were changed
25+ id : timestamp_check
26+ run : |
27+ git diff --quiet
28+ echo "timestamps_changed=$?" >> "$GITHUB_OUTPUT"
29+
30+ # TODO: find way to stop CI running if pushing to existing PR
31+ - name : Push new timestamps
32+ if : " ${{ steps.timestamp_check.outputs.timestamps_changed }} == 0"
33+ run : |
34+ git add environments/common/inventory/group_vars/all/defaults.yml
35+ git config user.name 'github-actions[bot]'
36+ git config user.email 'github-actions[bot]@users.noreply.github.com'
37+ git commit -m "Bumped repo timestamps"
38+ git push
39+
40+ build_fatimage :
41+ if : " ${{ steps.timestamp_check.outputs.timestamps_changed }} == 0"
42+ needs : upstream_check
43+ uses : stackhpc/ansible-slurm-appliance/.github/workflows/fatimage.yml
44+
45+ ci_and_pr :
46+ if : " ${{ steps.timestamp_check.outputs.timestamps_changed }} == 0"
47+ needs : build_fatimage
48+ runs-on : ubuntu-latest
49+ steps :
50+ - uses : actions/checkout@v2
51+
52+ - name : Bump CI with new images
53+ run : |
54+ git checkout auto/bump-timestamps
55+ sed -i 's/"RL8".*$/"RL8": "${{ needs.build_fatimage.outputs.openhpc-RL8-image }}"/' environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
56+ sed -i 's/"RL9".*$/"RL9": "${{ needs.build_fatimage.outputs.openhpc-RL9-image }}"/' environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
57+
58+ - name : Push new images
59+ run : |
60+ git add environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
61+ git config user.name 'github-actions[bot]'
62+ git config user.email 'github-actions[bot]@users.noreply.github.com'
63+ git commit -m "Bumped images"
64+ git push
65+
66+ - name : Check if PR exists
67+ id : pr-check
68+ run : |
69+ gh pr list --json headRefName --jq '.[].headRefName' | grep auto/bump-timestamps
70+ echo "pr_exists=$?" >> "$GITHUB_OUTPUT"
71+
72+ - name : Create PR
73+ if : ${{ steps.pr-check.outputs.pr_exists }}
74+ run : gh pr create --title "[Auto] Bump repo timestamps to latest" --base main --head auto/bump-timestamps
0 commit comments