Skip to content

Fetch and Save Data #251

Fetch and Save Data

Fetch and Save Data #251

Workflow file for this run

name: Fetch and Save Data
on:
schedule:
- cron: '0 8 * * 1-5' # Every weekday at 8am
push:
branches:
- master
workflow_dispatch:
jobs:
fetch_data:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '19'
- name: Install dependencies
run: npm install
- name: Fetch and save data
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
run: node fetchAndSaveData.js
- name: Check for failed jobs
id: check_failed_jobs
run: |
if grep -q '"conclusion": "failure"' data.json; then
echo "failed_jobs=true" >> $GITHUB_ENV
else
echo "failed_jobs=false" >> $GITHUB_ENV
fi
- name: Notify slack
if: ${{ env.failed_jobs == 'true' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: "There are failing pipelines!"
SLACK_USERNAME: Big brother
SLACK_MESSAGE: "Please check the pipelines: <https://tyktechnologies.github.io/qa-automation-utils/|link>"
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add data.json
git commit -m "Update data.json [skip ci]" || exit 0
git push