-
Notifications
You must be signed in to change notification settings - Fork 37
173 lines (152 loc) · 6.42 KB
/
maintenance.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Example/test maintenance (package-lock updating, formatting, linting)
on:
workflow_dispatch:
schedule:
# Run at 10:00 UTC (4:00 AM MT) every day
- cron: '0 10 * * *'
jobs:
determine-signing-key:
runs-on: ubuntu-latest
outputs:
signing-key-id: ${{ steps.set-key.outputs.key }}
steps:
- id: set-key
run: echo "key=C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0" >> $GITHUB_OUTPUT
determine-prefix:
runs-on: ubuntu-latest
outputs:
prefix: ${{ steps.set-prefix.outputs.prefix }}
steps:
- id: set-prefix
run: echo "prefix=maintenance-$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
create-branch-prefix:
needs:
- determine-signing-key
- determine-prefix
uses: ./.github/workflows/create_branch_prefix.yml
with:
prefix: ${{ needs.determine-prefix.outputs.prefix }}
version: $(jq -r '.version' package.json)
signing-key-id: ${{ needs.determine-signing-key.outputs.signing-key-id }}
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
prepare-maintenance:
name: Prepare Maintenance
needs:
- create-branch-prefix
- determine-signing-key
runs-on: ubuntu-latest
outputs:
test-infos: ${{ steps.get-test-infos.outputs.test-infos }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-branch-prefix.outputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/setup_dfx
- run: npm install
# Run global prettier/lint fixes
- name: Run Prettier
run: npx prettier --write .
- name: Run ESLint
run: npx eslint . --fix
- uses: ./.github/actions/commit_and_push
with:
branch-name: ${{ needs.create-branch-prefix.outputs.base-branch }}
commit-message: 'Example/test maintenance: formatting and linting'
gpg-signing-key: ${{ secrets.GPG_SIGNING_KEY }}
signing-key-id: ${{ needs.determine-signing-key.outputs.signing-key-id }}
- id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
directories: ./examples
update-test-dependencies:
needs:
- prepare-maintenance
- create-branch-prefix
- determine-signing-key
name: Update dependencies for ${{ matrix.test.name }}
runs-on: ubuntu-latest
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.prepare-maintenance.outputs.test-infos) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-branch-prefix.outputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/setup_dfx
# Update package-lock.json in test directory
- name: Update package-lock.json
working-directory: ${{ matrix.test.path }}
run: |
rm -f package-lock.json
npm install
- name: Create branch name
id: create-branch-name
uses: ./.github/actions/create_branch_name
with:
prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}
path: ${{ matrix.test.displayPath }}
- uses: ./.github/actions/commit_and_push
with:
branch-name: ${{ steps.create-branch-name.outputs.branch-name }}
commit-message: 'Example/test maintenance: update dependencies'
gpg-signing-key: ${{ secrets.GPG_SIGNING_KEY }}
create-branch: 'true'
signing-key-id: ${{ needs.determine-signing-key.outputs.signing-key-id }}
squash-branches:
needs:
- update-test-dependencies
- create-branch-prefix
- determine-signing-key
uses: ./.github/workflows/squash_branches.yml
with:
base-branch: ${{ needs.create-branch-prefix.outputs.base-branch }}
branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}
commit-message: 'Example/test maintenance: update dependencies'
signing-key-id: ${{ needs.determine-signing-key.outputs.signing-key-id }}
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
create-pr:
needs:
- squash-branches
- create-branch-prefix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Check for differences
id: check-diff
run: |
git fetch origin main
if git diff --quiet origin/main ${{ needs.create-branch-prefix.outputs.base-branch }}; then
echo "No differences found between branches"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.check-diff.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head ${{ needs.create-branch-prefix.outputs.base-branch }} \
--title "Example/test maintenance: update dependencies, formatting, and linting" \
--body "Automated PR for maintenance tasks:
- Updated package-lock.json files
- Fixed formatting with Prettier
- Fixed linting issues with ESLint"