-
Notifications
You must be signed in to change notification settings - Fork 2
82 lines (76 loc) · 2.46 KB
/
update-referentials.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: Update Referential
on:
workflow_dispatch:
schedule:
# At 06:00 on Monday
- cron: "0 6 * * 1"
jobs:
update-referential:
name: Update referentials
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "main"
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: Update referentials
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
NEXT_API_BEARER_TOKEN: ${{ secrets.NEXT_API_BEARER_TOKEN }}
run: |
cd scripts
npm ci
node update-agencies-referentiel.mjs
node update-categories-referentiel.mjs
node update-certifications-referentiel.mjs
node update-skills-referentiel.mjs
node update-tags-referentiel.mjs
node update-topics-referentiel.mjs
cd ..
git checkout -b chore/update_referentials
- name: Commit
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "🌱 Update referentials"
git push --set-upstream origin chore/update_referentials -f
- name: Create Pull Request
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
try {
const result = await github.rest.pulls.create({
title: '🌱 Update referentials',
owner,
repo,
head: 'chore/update_referentials',
base: 'main',
body: [
'This is an automated PR.',
'It updates all referentials with new data validated by the admins.'
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['automated pr', 'referential']
});
github.rest.pulls.requestReviewers({
owner,
repo,
pull_number: result.data.number,
reviewers: ['bengeois', 'ZenikAdrien']
});
} catch (error) {
if (error.status != 422) {
core.setFailed(error);
}
}