Fetch #1281
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: Fetch | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "00 15 * * *" | |
permissions: | |
contents: write | |
id-token: write # Required for OIDC token generation | |
jobs: | |
fetch: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.9.0' | |
cache: yarn | |
- name: Installing | |
run: yarn --frozen-lockfile --perfer-offline --link-duplicates | |
- name: Fetch data | |
run: | | |
yarn data:update | |
env: | |
OAUTH_CLIENT_ID: ${{ secrets.DILA_OAUTH_CLIENT_ID }} | |
OAUTH_CLIENT_SECRET: ${{ secrets.DILA_OAUTH_CLIENT_SECRET }} | |
- name: Get metadata | |
id: metadata | |
shell: bash | |
run: | | |
echo "::set-output name=data_status::$(git status -s ./data)" | |
echo "::set-output name=now::$(date +"%Y%m%d_%H%M")" | |
- name: Print metadata | |
run: | | |
echo "Data status ${{ steps.metadata.outputs.now }}" | |
echo "${{ steps.metadata.outputs.data_status }}" | |
- name: Check JSON | |
run: | | |
for filename in ./data/LEGITEXT*\.json; do | |
node -e "assert(require('$filename').children.length > 0)" || { | |
echo "Invalid JSON in $filename : should have children" | |
exit 1 | |
} | |
done | |
- name: Get GitHub App Token | |
id: token | |
uses: SocialGouv/token-bureau@main | |
with: | |
token-bureau-url: https://token-bureau.fabrique.social.gouv.fr | |
audience: socialgouv | |
- uses: EndBug/add-and-commit@v8 | |
if: ${{ steps.metadata.outputs.data_status }} | |
env: | |
HUSKY: "0" | |
GITHUB_TOKEN: ${{ steps.token.outputs.token }} | |
with: | |
add: "data" | |
author_name: ${{ secrets.SOCIALGROOVYBOT_NAME }} | |
author_email: ${{ secrets.SOCIALGROOVYBOT_EMAIL }} | |
message: "feat(data): ${{ steps.metadata.outputs.now }} update" | |
- name: Set Registry token | |
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc | |
env: | |
NPM_TOKEN: ${{ secrets.SOCIALGROOVYBOT_NPM_TOKEN }} | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v2 | |
with: | |
semantic_version: 17 | |
extra_plugins: | | |
@semantic-release/changelog@5.0.1 | |
@semantic-release/exec@5.0.0 | |
@semantic-release/git@9.0.0 | |
env: | |
GIT_AUTHOR_EMAIL: ${{ secrets.SOCIALGROOVYBOT_EMAIL }} | |
GIT_AUTHOR_NAME: ${{ secrets.SOCIALGROOVYBOT_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ secrets.SOCIALGROOVYBOT_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ secrets.SOCIALGROOVYBOT_NAME }} | |
GITHUB_TOKEN: ${{ steps.token.outputs.token }} | |
NPM_TOKEN: ${{ secrets.SOCIALGROOVYBOT_NPM_TOKEN }} | |
- uses: mattermost/action-mattermost-notify@master | |
if: failure() | |
with: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
TEXT: | | |
La mise à jour du dépôt legi-data (Legifrance Convention Collective) a échoué. | |
[Les logs sont disponibles ici](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |