DocGen Scheduler #783
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: DocGen Scheduler | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 1 * * 1-5' | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
name: Generate Documentation | |
steps: | |
- name: Run actions | |
run: | | |
FILE_NAME="docgen.yml" | |
WORKFLOW_NAME="DocGen" | |
WORKFLOW_ID=$(curl https://api.github.com/repos/${{ github.repository }}/actions/workflows | jq -c '.workflows[] | select( .name == "'$WORKFLOW_NAME'" )' | jq .id) | |
echo "Workflow id: $WORKFLOW_ID" | |
MAJOR_REFS=$(curl https://api.github.com/repos/${{ github.repository }}/branches | jq -r .[].name | grep -oP "^(1|2)\d_(1|2)") | |
echo "Major refs: $MAJOR_REFS" | |
for REF in $MAJOR_REFS | |
do | |
echo "Testing workflow in branch: $REF" | |
STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" https://github.com/${{ github.repository }}/blob/$REF/.github/workflows/$FILE_NAME) | |
echo "Status: $STATUS" | |
if [ "$STATUS" != "404" ]; then | |
echo "Starting $WORKFLOW_NAME for $REF branch" | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: Bearer ${{ secrets.DXROBOT_PAT }}" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/dispatches \ | |
-d '{"ref":"'$REF'"}' | |
fi | |
done |