data-update #2621
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 | |
| # ======================= | |
| # FORRT Website Deployment | |
| # ======================= | |
| # Purpose: Build and deploy the FORRT Hugo website | |
| # Triggers: Push to master, PRs, manual dispatch, or data updates | |
| # Target: Production deployment | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number to deploy (optional)' | |
| required: false | |
| type: string | |
| repository_dispatch: | |
| types: [data-update] | |
| 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: | |
| # ======================= | |
| # Repository Setup | |
| # ======================= | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }} | |
| fetch-depth: 0 | |
| # ======================= | |
| # Data Artifact Retrieval | |
| # ======================= | |
| - 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 }} | |
| search_artifacts: true | |
| if_no_artifact_found: warn | |
| # ======================= | |
| # Data Processing (Fallback) | |
| # ======================= | |
| - name: Run data processing if artifact missing | |
| id: data-processing | |
| if: steps.download-artifact.outcome == 'failure' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.FORRT_PAT }} | |
| run: | | |
| set -e | |
| # If this is a pull request, we can't easily trigger the external workflow and wait for it | |
| # in the same way (or maybe we can, but let's stick to the plan). | |
| # Actually, for PRs, we might want to just warn and proceed if it's not critical, | |
| # OR trigger it if we really need the data. | |
| # The original logic skipped it for PRs. | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "::warning::Data artifact missing in PR. Skipping trigger." | |
| echo "data_processing_triggered=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Determine branch ref to dispatch (must be a branch or tag) | |
| REF="${GITHUB_REF#refs/heads/}" | |
| if [ -z "$REF" ]; then | |
| REF="master" | |
| fi | |
| echo "🚀 Dispatching data-processing workflow for ref: $REF because artifact was missing" | |
| curl -s -X POST \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/${{ github.repository }}/actions/workflows/data-processing.yml/dispatches" \ | |
| -d "{\"ref\":\"$REF\", \"inputs\": {\"skip_deploy\": \"true\"}}" \ | |
| || { echo "::error::Failed to dispatch data-processing workflow"; exit 1; } | |
| echo "data_processing_triggered=true" >> $GITHUB_OUTPUT | |
| echo "⏳ Waiting for data-processing workflow run to start and complete..." | |
| attempts=0 | |
| max_attempts=180 | |
| interval=10 | |
| # Wait a bit for the run to be created | |
| sleep 10 | |
| while [ $attempts -lt $max_attempts ]; do | |
| # Get the latest run triggered by workflow_dispatch | |
| runs_json=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/${{ github.repository }}/actions/workflows/data-processing.yml/runs?event=workflow_dispatch&branch=$REF&per_page=1") | |
| run_id=$(echo "$runs_json" | jq -r '.workflow_runs[0].id') | |
| status=$(echo "$runs_json" | jq -r '.workflow_runs[0].status') | |
| conclusion=$(echo "$runs_json" | jq -r '.workflow_runs[0].conclusion') | |
| if [ -n "$run_id" ] && [ "$run_id" != "null" ]; then | |
| echo "Tracking data-processing run: $run_id (Status: $status)" | |
| if [ "$status" = "completed" ]; then | |
| if [ "$conclusion" = "success" ]; then | |
| echo "✅ data-processing workflow completed successfully" | |
| echo "run_id=$run_id" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "::error::data-processing workflow completed with conclusion: $conclusion" | |
| exit 1 | |
| fi | |
| fi | |
| fi | |
| attempts=$((attempts + 1)) | |
| sleep $interval | |
| done | |
| echo "::error::Timed out waiting for data-processing workflow" | |
| exit 1 | |
| # ======================= | |
| # Data Artifact Retrieval (Retry) | |
| # ======================= | |
| - name: Download data artifact (Retry) | |
| id: download-artifact-retry | |
| if: steps.download-artifact.outcome == 'failure' && steps.data-processing.outputs.data_processing_triggered == 'true' | |
| uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 | |
| with: | |
| workflow: data-processing.yml | |
| name: data-artifact | |
| path: . | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| run_id: ${{ steps.data-processing.outputs.run_id }} | |
| # ======================= | |
| # Hugo Build Environment | |
| # ======================= | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f | |
| with: | |
| hugo-version: ${{ env.HUGO_VERSION }} | |
| extended: ${{ env.HUGO_EXTENDED }} | |
| # ======================= | |
| # Website Build | |
| # ======================= | |
| - 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 }} | |
| HUGO_ENV: ${{ github.ref != 'refs/heads/master' && 'staging' || 'production' }} | |
| # ======================= | |
| # Deployment Artifact | |
| #======================================== | |
| # Upload built website as artifact for deployment | |
| #======================================== | |
| - name: Upload site artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: public/ | |
| retention-days: 1 | |
| #======================================== | |
| # Deploy website to staging GitHub Pages | |
| #======================================== | |
| deploy-test: | |
| name: Deploy - Test | |
| runs-on: ubuntu-22.04 | |
| concurrency: | |
| group: staging | |
| permissions: | |
| contents: write | |
| needs: build | |
| steps: | |
| #======================================== | |
| # Download website artifact for staging deployment | |
| #======================================== | |
| - name: Download Artifact - Website | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: ${{ github.repository }}/forrt-website | |
| #======================================== | |
| # Deploy website to staging GitHub Pages | |
| #======================================== | |
| - 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 website to production GitHub Pages | |
| #======================================== | |
| deploy-prod: | |
| name: Deploy - Production | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| needs: | |
| - deploy-test | |
| if: ((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' || github.event_name == 'repository_dispatch') && github.event.repository.fork == false | |
| steps: | |
| #======================================== | |
| # Download website artifact for production deployment | |
| #======================================== | |
| - name: Download Artifact - Website | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: forrt-website-${{ github.run_number }} | |
| path: ${{ github.repository }}/forrt-website | |
| #======================================== | |
| # Deploy website to production GitHub Pages | |
| #======================================== | |
| - 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 |