Skip to content

Commit

Permalink
Add GitHub Actions workflow to update chains and flex index files (#747)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflow to update chains and flex index files

* Add missing push command and simplify commit command

* Run after push to main and on cron schedule
  • Loading branch information
dcroote authored Jun 7, 2024
1 parent 7083722 commit 497cd75
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/refresh-index-chains.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Update chains and flex index files
on:
push:
branches:
- main
schedule:
# Run every day at 12:00
- cron: '0 12 * * *'

jobs:
conditional_PR_generation:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- run: yarn install

- name: Refresh chains and flex index files
# If changes are present after build, set env variable
run: |
yarn axios:build
yarn docs:build
yarn flex:build
yarn flex:test
git diff --quiet --exit-code || echo "CHANGES_FOUND=true" >> $GITHUB_ENV
- name: Create PR if files have changed
if: env.CHANGES_FOUND == 'true'
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git checkout -b ${{ env.BRANCH_NAME }}
git commit -am "Update chains and flex index files"
git push origin ${{ env.BRANCH_NAME }}
gh pr create -B main -H ${{ env.BRANCH_NAME }} --title 'Update chains and flex index files' --body 'Created by GitHub Actions Cron Job' --reviewer wkande,dcroote
env:
BRANCH_NAME: "actions-chains-index-update"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 497cd75

Please sign in to comment.