Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/actions-node24-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'dle.dev': patch
---

Migrate the GitHub Actions deployment workflows off Node 20-based actions by upgrading the shared setup actions and replacing the Cloudflare Wrangler action with a local Pages deploy action that preserves deployment URLs in the GitHub UI.
8 changes: 4 additions & 4 deletions .github/actions/env-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ name: Setup Environment
runs:
steps:
- name: Git Composite Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: ${{ inputs.fetch-depth }}
ref: ${{ inputs.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
- name: Setup PNPM
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@v5
with:
version: ${{ inputs.pnpm-version }}

- id: pnpm-cache
name: Setup PNPM cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
# include node version + lockfile hash so caches are stable across node changes
key: ${{ runner.os }}-pnpm-v${{ inputs.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand Down
94 changes: 94 additions & 0 deletions .github/actions/pages-deploy/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Deploy Pages
description: Deploy a Cloudflare Pages build and expose the deployment URLs

inputs:
account-id:
description: Cloudflare account ID
required: true
api-token:
description: Cloudflare API token
required: true
branch:
description: Branch name to attach to the deployment
required: true
directory:
default: ./.svelte-kit/cloudflare
description: Directory to deploy
required: false
project-name:
description: Cloudflare Pages project name
required: true

outputs:
deployment-url:
description: URL of the deployed Pages site
value: ${{ steps.deploy.outputs.deployment-url }}
pages-deployment-alias-url:
description: Alias URL for preview deployments when available
value: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
pages-deployment-id:
description: Cloudflare Pages deployment ID when available
value: ${{ steps.deploy.outputs.pages-deployment-id }}
pages-environment:
description: Cloudflare Pages deployment environment when available
value: ${{ steps.deploy.outputs.pages-environment }}

runs:
using: composite
steps:
- id: deploy
name: Deploy Pages
shell: bash
env:
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.account-id }}
CLOUDFLARE_API_TOKEN: ${{ inputs.api-token }}
DEPLOY_BRANCH: ${{ inputs.branch }}
DEPLOY_DIRECTORY: ${{ inputs.directory }}
DEPLOY_PROJECT_NAME: ${{ inputs.project-name }}
run: |
set -euo pipefail

output_dir="$(mktemp -d)"
export WRANGLER_OUTPUT_FILE_DIRECTORY="$output_dir"

pnpm wrangler pages deploy "$DEPLOY_DIRECTORY" \
--project-name="$DEPLOY_PROJECT_NAME" \
--branch="$DEPLOY_BRANCH"

artifact="$(find "$output_dir" -maxdepth 1 -type f -name 'wrangler-output-*.json' | head -n 1)"

if [ -z "$artifact" ]; then
echo "Wrangler deployment output was not written" >&2
exit 1
fi

ARTIFACT_PATH="$artifact" GITHUB_OUTPUT_FILE="$GITHUB_OUTPUT" node --input-type=module <<'EOF'
import fs from 'node:fs';

const output = JSON.parse(fs.readFileSync(process.env.ARTIFACT_PATH, 'utf8'));
const entry = output?.type === 'pages-deploy-detailed'
? output
: Array.isArray(output)
? output.find((item) => item?.type === 'pages-deploy-detailed')
: undefined;

if (!entry?.url) {
throw new Error('Pages deployment URL not found in Wrangler output');
}

const lines = [`deployment-url=${entry.url}`];

if (entry.alias) {
lines.push(`pages-deployment-alias-url=${entry.alias}`);
}

if (entry.deployment_id) {
lines.push(`pages-deployment-id=${entry.deployment_id}`);
}

if (entry.environment) {
lines.push(`pages-environment=${entry.environment}`);
}

fs.appendFileSync(process.env.GITHUB_OUTPUT_FILE, `${lines.join('\n')}\n`);
EOF
14 changes: 7 additions & 7 deletions .github/workflows/changesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/env-setup
Expand All @@ -40,20 +40,20 @@ jobs:

- name: Publish Staging
id: deploy
uses: cloudflare/wrangler-action@v3
uses: ./.github/actions/pages-deploy
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy ./.svelte-kit/cloudflare --project-name=dle-dev-staging --branch=master
packageManager: pnpm
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
branch: master
project-name: dle-dev-staging

version:
name: Create Release PR
needs: [deploy-staging]
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/env-setup
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/env-setup
Expand All @@ -41,9 +41,9 @@ jobs:

- name: Publish Web App
id: deploy
uses: cloudflare/wrangler-action@v3
uses: ./.github/actions/pages-deploy
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy ./.svelte-kit/cloudflare --project-name=dle-dev --branch=master
packageManager: pnpm
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
branch: master
project-name: dle-dev
2 changes: 1 addition & 1 deletion .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/env-setup
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/env-setup
Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# with:
# fetch-depth: 1
- name: Setup environment
Expand All @@ -60,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# with:
# fetch-depth: 1
- name: Setup environment
Expand All @@ -76,18 +76,18 @@ jobs:
pnpm run build
- name: Publish Web App
id: deploy
uses: cloudflare/wrangler-action@v3
uses: ./.github/actions/pages-deploy
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy ./.svelte-kit/cloudflare --project-name=dle-dev-staging --branch=${{ github.head_ref }}
packageManager: pnpm
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
branch: ${{ github.head_ref }}
project-name: dle-dev-staging
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# with:
# fetch-depth: 1
- name: Setup environment
Expand Down
Loading