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
50 changes: 50 additions & 0 deletions .github/workflows/check-build-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# .github/workflows/build-pr.yml
name: 1 - Check and Build Web Page PR

on:
pull_request:
branches: ["main"]

jobs:
linter:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: 3.12
cache: pip

- name: pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: "--from-ref origin/main --to-ref HEAD"

- name: Install dependencies
run: pip install -r requirements.txt
- name: Build docs
run: mkdocs build

- name: Upload Static Site Artifact
uses: actions/upload-artifact@v4
with:
name: preview-site
path: site/

# NEW: Save the PR number to a file
- name: Save PR number
run: echo ${{ github.event.pull_request.number }} > pr-number.txt

# NEW: Upload the PR number as its own artifact
- name: Upload PR Number Artifact
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: pr-number.txt
27 changes: 27 additions & 0 deletions .github/workflows/clean-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .github/workflows/build-pr.yml
name: 1 - Clean Web Page PR

on:
pull_request:
types: [closed]

jobs:
clean:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
deployments: write
pull-requests: write
steps:

# NEW: Save the PR number to a file
- name: Save PR number
run: echo ${{ github.event.pull_request.number }} > pr-number.txt

# NEW: Upload the PR number as its own artifact
- name: Upload PR Number Artifact
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: pr-number.txt
71 changes: 71 additions & 0 deletions .github/workflows/delete-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# .github/workflows/deploy-pr.yml
name: 2 - Clean Web Page PR

on:
workflow_run:
workflows: ["1 - Clean Web Page PR"]
types: [completed]

# CRITICAL: Grant the workflow permission to write comments on PRs
permissions:
pull-requests: write

jobs:
deploy-preview:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
environment: Cloudflare Pages
permissions:
# actions: read # Only required for private GitHub Repo
contents: read
deployments: write
pull-requests: write

steps:
# NEW: Download the PR metadata artifact
- name: Download PR Number Artifact
uses: actions/download-artifact@v4
with:
name: pr-metadata
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set PR Number Context
run: |
PR_NUMBER=$(cat pr-number.txt)
# This syntax makes it available to subsequent steps as ${{ env.PR_NUMBER }}
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV

- name: Delete Cloudflare Deployments
env:
# Pull your secrets securely
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
PROJECT_NAME: "openshift-examples"
PR_NUMBER: ${{ env.PR_NUMBER }}
run: |
echo "Cleaning up deployments for PR #$PR_NUMBER..."

# 1. Install the Cloudflare Wrangler CLI
npm install -g wrangler

# 2. Fetch all project deployments as a JSON payload
wrangler pages deployment list --project-name $PROJECT_NAME --json > deployments.json

# 3. Use 'jq' to filter the JSON for deployments matching this PR's branch
# (In our previous step, we named the branch 'pr-123')
TARGET_IDS=$(jq -r ".[] | select(.Branch == \"pr-$PR_NUMBER\") | .Id" deployments.json)

# Check if any deployments were actually found
if [ -z "$TARGET_IDS" ]; then
echo "No preview deployments found for pr-$PR_NUMBER."
exit 0
fi

# 4. Loop through the matching IDs and force-delete them
for ID in $TARGET_IDS; do
echo "Deleting deployment ID: $ID..."
wrangler pages deployment delete $ID --project-name $PROJECT_NAME --force
done

echo "🎉 Cleanup complete!"
66 changes: 66 additions & 0 deletions .github/workflows/deploy-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# .github/workflows/deploy-pr.yml
name: 2 - Deploy Web Page PR

on:
workflow_run:
workflows: ["1 - Check and Build Web Page PR"]
types: [completed]

# CRITICAL: Grant the workflow permission to write comments on PRs
permissions:
pull-requests: write

jobs:
deploy-preview:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
environment: Cloudflare Pages
permissions:
# actions: read # Only required for private GitHub Repo
contents: read
deployments: write
pull-requests: write

steps:
- name: Download Site Artifact
uses: actions/download-artifact@v4
with:
name: preview-site
path: site/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

# NEW: Download the PR metadata artifact
- name: Download PR Number Artifact
uses: actions/download-artifact@v4
with:
name: pr-metadata
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set PR Number Context
run: |
PR_NUMBER=$(cat pr-number.txt)
# This syntax makes it available to subsequent steps as ${{ env.PR_NUMBER }}
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV

- name: Deploy
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: |
pages deploy site/ --project-name=openshift-examples --branch pr-${{ env.PR_NUMBER }}
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CMD_OUTPUT: ${{ steps.deploy.outputs.command-output }}
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
run: |
gh pr comment ${{ env.PR_NUMBER }} \
--repo ${{ github.repository }} \
--body "🚀 **Preview Deployment Success!** View your live changes here: $DEPLOYMENT_URL\n\n$CMD_OUTPUT"
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: 'Deploy'
on:
push:
branches:
- main

jobs:
deploy:
permissions:
# actions: read # Only required for private GitHub Repo
contents: read
deployments: write
pull-requests: write
runs-on: ubuntu-latest
environment: Cloudflare Pages
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: 3.12
cache: 'pip'
- name: Install Dependencies
run: |
pip install -r requirements.txt

- name: Build Docs Website
run: mkdocs build

- name: Deploy to Cloudflare Pages
uses: andykenward/github-actions-cloudflare-pages@v3.0.0
id: pages
with:
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare-project-name: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
directory: site
github-token: ${{ secrets.GITHUB_TOKEN }}
github-environment: Cloudflare Pages
23 changes: 0 additions & 23 deletions .github/workflows/pr-check.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/pr-close.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/publish-main-releases.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ rosetta
.local
share
hooks/__pycache__/

# wrangler files
.wrangler
.dev.vars*
!.dev.vars.example
.env*
!.env.example
14 changes: 14 additions & 0 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "openshift-examples",
"compatibility_date": "2026-04-30",
"observability": {
"enabled": true
},
"assets": {
"directory": "site"
},
"compatibility_flags": [
"nodejs_compat"
]
}
Loading