-
Notifications
You must be signed in to change notification settings - Fork 54
80 lines (72 loc) · 2.52 KB
/
update_tutorials.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
name: Update tutorial workflows
on:
workflow_dispatch:
inputs:
rose_ref:
description: The rose branch to update the tutorials on
required: false
cylc_ref:
description: The cylc-flow branch to update the tutorials from
required: false
schedule:
- cron: '37 04 6,21 * *' # 04:37, on the 6th & 21st of each month
jobs:
update_tutorials:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
ROSE_REF: ${{ inputs.rose_ref || 'master' }}
CYLC_REF: ${{ inputs.cylc_ref || 'master' }}
steps:
- name: Checkout rose
uses: actions/checkout@v4
with:
ref: ${{ env.ROSE_REF }}
path: rose
- name: Checkout cylc-flow
uses: actions/checkout@v4
with:
repository: cylc/cylc-flow
ref: ${{ env.CYLC_REF }}
path: cylc-flow
- name: Configure Git
uses: cylc/release-actions/configure-git@v1
- name: Update tutorials
run: |
rsync -va cylc-flow/cylc/flow/etc/tutorial/ rose/metomi/rose/etc/tutorial/ \
--exclude=consolidation-tutorial \
--exclude=inheritance-tutorial \
--exclude=message-trigger-tutorial \
--exclude=retries-tutorial \
--exclude=runtime-introduction \
--exclude=runtime-tutorial
- name: Check for changes
id: check
working-directory: rose
run: |
STATUS="$(git status --short)"
if [[ -n "$STATUS" ]]; then
echo "$STATUS"
echo "::set-output name=changed::true"
else
echo "::notice::No updates to the tutorials"
fi
- name: Create PR
if: steps.check.outputs.changed
working-directory: rose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BODY: |
This PR pulls in changes to the tutorial workflow from cylc flow.
- **Remember to open an equivalent PR on maintenance branches if needed**
- This can be done via [workflow dispatch](https://github.com/metomi/rose/actions/workflows/update_tutorials.yml)
- Remember to delete the branch once merged
run: |
git config push.default current
git checkout -b "update-tutorials-${{ github.run_number }}"
git add -A
git commit -m "Update tutorials from cylc-flow"
git push
gh pr create --title "Update Tutorial Workflow" \
--body "$PR_BODY" \
--base "$ROSE_REF"