Update Referential #98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |