Deploy Pages #8
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: Refresh market data and deploy Pages | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: "30 18 * * 1-5" | |
| timezone: America/Los_Angeles | |
| workflow_dispatch: | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| if: github.event_name != 'push' | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| cache-dependency-path: scripts/requirements-market.txt | |
| - name: Refresh market data | |
| if: github.event_name != 'push' | |
| env: | |
| FORCE_MARKET_DATA_WRITE: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| pip install -r scripts/requirements-market.txt | |
| python scripts/update_market_data.py | |
| - name: Commit new market data | |
| if: github.event_name != 'push' | |
| run: | | |
| if git diff --quiet -- assets/data/sp500-3m.json; then | |
| echo "No new market data to commit." | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add assets/data/sp500-3m.json | |
| git commit -m "Update S&P 500 market data" | |
| git push | |
| fi | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "2.7" | |
| bundler-cache: true | |
| - name: Configure GitHub Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Build site | |
| run: bundle exec jekyll build | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./_site | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |