Lesson Plans #1468
Workflow file for this run
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: deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 1 * * *' # 1 AM UTC (1 hour after data processing) | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| actions: read # Needed for artifact access | |
| env: | |
| HUGO_VERSION: "0.123.3" | |
| HUGO_EXTENDED: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-depth: 0 | |
| - name: Try to download data artifact | |
| id: download-artifact | |
| uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 | |
| continue-on-error: true | |
| with: | |
| workflow: data-processing.yml | |
| name: data-artifact | |
| path: . | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run data processing if needed | |
| if: steps.download-artifact.outcome == 'failure' | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| GA_API_CREDENTIALS: ${{ secrets.GA_API_CREDENTIALS }} | |
| GA_PROPERTY_ID: ${{ secrets.GA_PROPERTY_ID }} | |
| run: | | |
| # Install Python dependencies | |
| python3 -m pip install -r ./requirements.txt | |
| # Generate data files | |
| python3 scripts/forrt_contribs/tenzing.py | |
| python3 content/resources/resource.py | |
| mv scripts/forrt_contribs/tenzing.md content/contributors/tenzing.md | |
| # Download GA data if possible | |
| if [ "${{ github.event_name }}" != 'pull_request' ]; then | |
| python scripts/download_ga_data.py | |
| fi | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f | |
| with: | |
| hugo-version: ${{ env.HUGO_VERSION }} | |
| extended: ${{ env.HUGO_EXTENDED }} | |
| - name: Build site | |
| run: | | |
| if [ "$BRANCH" != 'refs/heads/master' ]; then | |
| hugo --gc --minify --cleanDestinationDir --destination public --baseURL https://staging.forrt.org | |
| else | |
| hugo --gc --minify --cleanDestinationDir --destination public | |
| fi | |
| env: | |
| BRANCH: ${{ github.ref }} | |
| - name: Upload site artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: public/ | |
| retention-days: 1 | |
| deploy-test: | |
| name: Deploy - Test | |
| runs-on: ubuntu-22.04 | |
| concurrency: | |
| group: staging | |
| permissions: | |
| contents: write | |
| needs: build | |
| steps: | |
| - name: Download Artifact - Website | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: ${{ github.repository }}/forrt-website | |
| - name: Deploy - GitHub Pages | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e | |
| with: | |
| personal_token: ${{ secrets.STAGING_GITHUB_TOKEN }} | |
| publish_dir: ${{ github.repository }}/forrt-website | |
| external_repository: forrtproject/webpage-staging | |
| publish_branch: staging | |
| cname: staging.forrt.org | |
| deploy-prod: | |
| name: Deploy - Production | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| needs: | |
| - deploy-test | |
| if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master' && github.event.repository.fork == false | |
| steps: | |
| - name: Download Arfifact - Website | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: ${{ github.repository }}/forrt-website | |
| - name: Deploy - GitHub Pages | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ${{ github.repository }}/forrt-website | |
| publish_branch: gh-pages | |
| cname: forrt.org |