Fetch #1687
This file contains hidden or 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 12 * * *" | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| fetch: | |
| name: Fetch | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20.17.0' | |
| cache: yarn | |
| - name: Update npm (required for npm trusted publishing) | |
| run: npm install -g npm@latest | |
| - 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: Fetch CC index from CDTN | |
| run: | | |
| curl https://cdtn-prod-public.s3.gra.io.cloud.ovh.net/published/agreements/index.json -o - | jq > data/index.json | |
| - 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/*\.json; do | |
| node "$filename" > /dev/null || { | |
| echo "Invalid JSON in $filename" | |
| exit 1 | |
| } | |
| done | |
| - name: Check articles index is valid | |
| run: | | |
| node "data/articles/index.json" > /dev/null || { | |
| echo "Invalid JSON in data/articles/index.json" | |
| exit 1 | |
| } | |
| - 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: Semantic Release | |
| id: semantic | |
| uses: cycjimmy/semantic-release-action@ba330626c4750c19d8299de843f05c7aa5574f62 | |
| with: | |
| semantic_version: 25.0.1 | |
| extra_plugins: | | |
| @semantic-release/changelog@6.0.3 | |
| @semantic-release/git@10.0.1 | |
| 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 }} | |
| - name: Publish to NPM | |
| if: ${{ steps.semantic.outputs.new_release_published == 'true' }} | |
| run: npm publish | |
| - name: Publish types to NPM | |
| if: ${{ steps.semantic.outputs.new_release_published == 'true' }} | |
| run: | | |
| rm -rf data | |
| sed -i "s/@socialgouv\/kali-data/@socialgouv\/kali-data-types/g" package.json | |
| { rm package.json; jq 'del(.dependencies)' > package.json; } < package.json | |
| npm publish | |
| - uses: mattermost/action-mattermost-notify@master | |
| if: failure() | |
| with: | |
| MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
| TEXT: | | |
| La mise à jour du dépôt kali-data a échoué. | |
| [Les logs sont disponibles ici](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |