Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ This document describes the GitHub Actions workflows used in the FORRT website r

Builds the Hugo site and deploys to GitHub Pages (`gh-pages` branch).

It uses the newest `data-artifact` and `announcements-artifact` from runs on `main` only. Runs of `data-processing.yml` or `create_announcements.yml` dispatched from another branch, for example to test a pipeline change, upload `*-preview` artifacts (#1030) that production never uses (#960). Staging can opt in to a branch's data artifact only; it never uses branch announcement artifacts. To stage branch data, run `data-processing.yml` on the branch, then dispatch `staging-aggregate.yaml` with `data_branch` set to that branch (combine with `single_pr` to stage only the PR that changes the pipeline). Production never uses it. If a branch other than `main` is named and has no data artifact, staging stops with an error rather than substituting `main`'s data (`data_branch: main` behaves like leaving it empty). For default staging runs and production, a missing data artifact makes the fallback dispatch `data-processing.yml` on `main`; a missing announcements artifact is not regenerated by these workflows.

### [staging-aggregate.yaml](staging-aggregate.yaml)
**Staging deployment for pull requests**

Expand Down Expand Up @@ -157,4 +159,5 @@ All workflows support `workflow_dispatch` for manual execution via GitHub Action
| `cleanup-branches` | `dry_run` | Preview deletions without executing |
| `staging-aggregate` | `force_deploy` | Deploy even with no PRs |
| `staging-aggregate` | `single_pr` | Deploy only specified PR number |
| `staging-aggregate` | `data_branch` | Use that branch's data artifact instead of main's |
| `data-processing` | `skip_deploy` | Skip triggering production deploy |
20 changes: 11 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ jobs:
path: .
github_token: ${{ secrets.GITHUB_TOKEN }}
search_artifacts: true
if_no_artifact_found: warn
branch: main # only main's runs feed deploys; branch test runs must not (#960)
if_no_artifact_found: fail # continue-on-error is set; failure triggers the fallback below
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved

# =======================
# Data Processing (Fallback)
Expand All @@ -89,14 +90,14 @@ jobs:
exit 0
fi

# Determine branch ref to dispatch (must be a branch or tag)
REF="${GITHUB_REF#refs/heads/}"
if [ -z "$REF" ]; then
REF="main"
fi
# Always regenerate from main: deploys use main's data only (#960)
REF="main"

# The run this job dispatches is the first one newer than any that exists now
RUNS_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/data-processing.yml/runs?event=workflow_dispatch&branch=$REF&per_page=100"
BEFORE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" "$RUNS_URL" | jq '[.workflow_runs[].id] | max // 0')
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved
echo "🚀 Dispatching data-processing workflow for ref: $REF because artifact was missing"
curl -s -X POST \
curl -sSf -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" \
Expand All @@ -115,9 +116,9 @@ jobs:
sleep 10

while [ $attempts -lt $max_attempts ]; do
# Get the latest run triggered by workflow_dispatch
# The first run created after the dispatch is ours
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")
"$RUNS_URL" | jq --argjson before "$BEFORE" '{workflow_runs: [.workflow_runs[] | select(.id > $before)] | sort_by(.id)}')

run_id=$(echo "$runs_json" | jq -r '.workflow_runs[0].id')
status=$(echo "$runs_json" | jq -r '.workflow_runs[0].status')
Expand Down Expand Up @@ -172,6 +173,7 @@ jobs:
path: .announcements
github_token: ${{ secrets.GITHUB_TOKEN }}
search_artifacts: true
branch: main # only main's runs feed deploys; branch test runs must not (#960)
if_no_artifact_found: warn

- name: Apply announcements
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/rebrand-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
path: ${{ runner.temp }}/artifacts/data
github_token: ${{ secrets.GITHUB_TOKEN }}
search_artifacts: true
branch: main # as in deploy.yaml: only main's runs, never a branch test run (#960)
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
if_no_artifact_found: warn

- name: Download announcements artifact
Expand All @@ -87,6 +88,7 @@ jobs:
path: ${{ runner.temp }}/artifacts/announcements
github_token: ${{ secrets.GITHUB_TOKEN }}
search_artifacts: true
branch: main # as in deploy.yaml: only main's runs, never a branch test run (#960)
if_no_artifact_found: warn

- name: Apply artifacts to both checkouts
Expand Down
38 changes: 27 additions & 11 deletions .github/workflows/staging-aggregate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ on:
required: false
type: boolean
default: false
data_branch:
description: 'Use the data artifact from this branch instead of main (to stage a data-processing change; run data-processing.yml on that branch first)'
required: false
type: string
default: ''

# Workflow-level concurrency to queue staging builds (wait instead of cancel)
concurrency:
Expand Down Expand Up @@ -280,11 +285,14 @@ jobs:
continue-on-error: true
with:
workflow: data-processing.yml
name: data-artifact
# Branch runs of data-processing.yml upload data-artifact-preview (#1030)
name: ${{ (github.event.inputs.data_branch != '' && github.event.inputs.data_branch != 'main') && 'data-artifact-preview' || 'data-artifact' }}
path: .staging-data-artifact
github_token: ${{ secrets.GITHUB_TOKEN }}
search_artifacts: true
if_no_artifact_found: warn
# main's runs only, unless a manual run names a branch to stage its data (#960)
branch: ${{ github.event.inputs.data_branch || 'main' }}
if_no_artifact_found: fail # continue-on-error is set; failure triggers the fallback below

- name: Select newer committed or artifact data
if: steps.download-artifact.outcome == 'success'
Expand All @@ -295,9 +303,17 @@ jobs:
# =======================
# Data Processing (Fallback)
# =======================
- name: Stop if the requested branch's data artifact is missing
if: steps.download-artifact.outcome == 'failure' && github.event.inputs.data_branch != '' && github.event.inputs.data_branch != 'main'
env:
DATA_BRANCH: ${{ github.event.inputs.data_branch }} # via env, never interpolated into the script
run: |
echo "::error::No data artifact from branch \"$DATA_BRANCH\". Run data-processing.yml on that branch first; staging won't substitute main's data."
exit 1

- name: Run data processing if artifact missing
id: data-processing
if: steps.download-artifact.outcome == 'failure'
if: steps.download-artifact.outcome == 'failure' && (github.event.inputs.data_branch == '' || github.event.inputs.data_branch == 'main')
env:
GITHUB_TOKEN: ${{ secrets.FORRT_PAT }}
run: |
Expand All @@ -310,14 +326,14 @@ jobs:
exit 0
fi

# Determine branch ref to dispatch (must be a branch or tag)
REF="${GITHUB_REF#refs/heads/}"
if [ -z "$REF" ]; then
REF="main"
fi
# Always regenerate from main: deploys use main's data only (#960)
REF="main"

# The run this job dispatches is the first one newer than any that exists now
RUNS_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/data-processing.yml/runs?event=workflow_dispatch&branch=$REF&per_page=100"
BEFORE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" "$RUNS_URL" | jq '[.workflow_runs[].id] | max // 0')
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved
echo "🚀 Dispatching data-processing workflow for ref: $REF because artifact was missing"
curl -s -X POST \
curl -sSf -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" \
Expand All @@ -336,9 +352,9 @@ jobs:
sleep 10

while [ $attempts -lt $max_attempts ]; do
# Get the latest run triggered by workflow_dispatch
# The first run created after the dispatch is ours
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")
"$RUNS_URL" | jq --argjson before "$BEFORE" '{workflow_runs: [.workflow_runs[] | select(.id > $before)] | sort_by(.id)}')

run_id=$(echo "$runs_json" | jq -r '.workflow_runs[0].id')
status=$(echo "$runs_json" | jq -r '.workflow_runs[0].status')
Expand Down
Loading