Skip to content

Update Referential

Update Referential #43

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@v3
with:
fetch-depth: 0
ref: "main"
- uses: actions/setup-node@v3
with:
node-version: 16
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: ['benjaminbrgs', 'ZenikAdrien', 'MailyLehoux']
});
} catch (error) {
if (error.status != 422) {
core.setFailed(error);
}
}