Auto Update Portfolios #439
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: Auto Update Portfolios | |
| on: | |
| schedule: | |
| - cron: "0 */6 * * *" # every 6 hours | |
| workflow_dispatch: # manual trigger | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-periodically: | |
| runs-on: ubuntu-latest | |
| env: | |
| FETCH_TOKEN: ${{ secrets.FETCH_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false # avoid conflicts when pushing manually | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| - name: Run script | |
| run: node scripts/sync_portfolios.js | |
| - name: Commit & Push changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add data/portfolios.json | |
| git diff --cached --quiet && echo "✅ No changes to commit" && exit 0 | |
| git commit -m "🔄 Auto updated portfolio data [skip ci]" | |
| git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref_name }} |