Skip to content

Check agreements by enterprise has been updated (CRON) #121

Check agreements by enterprise has been updated (CRON)

Check agreements by enterprise has been updated (CRON) #121

# This workflow check if the data (https://www.data.gouv.fr/fr/datasets/liste-des-conventions-collectives-par-entreprise-siret/) has regular update which is done manually.
# Alerts are sent to https://mattermost.fabrique.social.gouv.fr/default/channels/cdtn-alerts
name: Check agreements by enterprise has been updated (CRON)
on:
schedule:
- cron: "00 09 * * 1"
workflow_dispatch:
jobs:
liste-des-conventions-collectives-par-entreprise-siret:
name: Check last update on data.gouv.fr
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check agreements by enterprise has been updated
run: |
last=$(curl 'https://www.data.gouv.fr/api/1/datasets/liste-des-conventions-collectives-par-entreprise-siret/' | jq -r '.resources[0].last_modified' | sed 's/\..*//')
current=$(date -d "`date`" +"%s")
last_update=$(date -d $last +"%s")
days_diff=$(( ($current - $last_update) / (24*3600) ))
if [ $days_diff -gt 31 ]
then
echo "/!\ Data has not been updated since $days_diff days!"
exit 1
fi
echo "Data has been updated $days_diff days ago"
- name: Create the Mattermost Message
if: failure()
run: |
echo "{\"text\":\"La liste des conventions collectives par entreprise siret n'a pas été mise à jour depuis plus de 1 mois (WEEZ) : ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\"}" > mattermost.json
- uses: mattermost/action-mattermost-notify@master
if: failure()
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}