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
129 changes: 129 additions & 0 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Deploy Preview

on:
workflow_call:
inputs:
pr_number:
required: true
type: string
action:
required: true
type: string
description: "create or delete preview"
secrets:
TOKEN:
required: true

permissions:
contents: write
pull-requests: write

jobs:
deploy-preview:
name: Deploy Preview
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
ref: gh-pages
path: gh-pages

- name: Create preview directory and copy files
if: inputs.action == 'create'
run: |
mkdir -p gh-pages/preview/PR${{ inputs.pr_number }}

- name: Download preview build artifact
if: inputs.action == 'create'
uses: actions/download-artifact@v4
with:
name: preview-build-pr-${{ inputs.pr_number }}
path: gh-pages/preview/PR${{ inputs.pr_number }}

- name: Debug List gh-pages directory contents
if: inputs.action == 'create'
run: |
echo "=== gh-pages root directory ==="
ls -la gh-pages/
echo ""
echo "=== preview directory ==="
ls -la gh-pages/preview/
echo ""
echo "=== specific PR preview directory ==="
ls -la gh-pages/preview/PR${{ inputs.pr_number }}/
echo ""
echo "=== PR preview directory contents (first level) ==="
find gh-pages/preview/PR${{ inputs.pr_number }}/ -maxdepth 1 -type f | head -20
echo ""
echo "=== Checking for index.html ==="
if [ -f "gh-pages/preview/PR${{ inputs.pr_number }}/index.html" ]; then
echo "index.html exists"
echo "First few lines of index.html:"
head -10 gh-pages/preview/PR${{ inputs.pr_number }}/index.html
else
echo "index.html NOT found"
fi

- name: Remove preview directory
if: inputs.action == 'delete'
run: |
rm -rf gh-pages/preview/PR${{ inputs.pr_number }}

- name: Commit and push changes
run: |
cd gh-pages
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

if [ "${{ inputs.action }}" = "create" ]; then
git add preview/PR${{ inputs.pr_number }}
git commit -m "Add preview for PR #${{ inputs.pr_number }}"
else
git add -A
git commit -m "Remove preview for PR #${{ inputs.pr_number }}"
fi

git push origin gh-pages

- name: Comment on PR
if: inputs.action == 'create'
uses: actions/github-script@v7
with:
script: |
const previewUrl = `https://${{ github.repository_owner }}.github.io/execution-apis/preview/PR${{ inputs.pr_number }}/`;
github.rest.issues.createComment({
issue_number: ${{ inputs.pr_number }},
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}',
body: `🚀 **Deploy Preview Available!**

Your changes are now available for preview at: **${previewUrl}**

This preview will be automatically removed when the PR is merged.`
});

- name: Remove preview comment
if: inputs.action == 'delete'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
issue_number: ${{ inputs.pr_number }},
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}'
});

const previewComment = comments.find(comment =>
comment.body.includes('Deploy Preview Available!') &&
comment.user.login === 'github-actions[bot]'
);

if (previewComment) {
await github.rest.issues.deleteComment({
comment_id: previewComment.id,
owner: '${{ github.repository_owner }}',
repo: '${{ github.event.repository.name }}'
});
}
73 changes: 69 additions & 4 deletions .github/workflows/test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ on:
pull_request:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
types:
- opened
- reopened
- synchronize
- closed
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22, 24]
node-version: [20, 22]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -29,4 +36,62 @@ jobs:
- name: Test build website
run: |
npm run build
npm run build:docs
npm run build:docs

test-deploy-24:
name: Deploy 24
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
strategy:
matrix:
node-version: [24]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: npm install --frozen-lockfile
- name: Update Gatsby config for preview
run: |
cd docs/config
# Update gatsby-config.js to use preview path prefix
sed -i 's|pathPrefix: "/execution-apis"|pathPrefix: "/execution-apis/preview/PR${{ github.event.number }}"|g' gatsby-config.js
sed -i 's|siteUrl: "https://.*"|siteUrl: "https://${{ github.repository_owner }}.github.io"|g' gatsby-config.js

- name: Build preview version
run: |
cd ../..
npm run build:docs

- name: Upload preview build artifact
uses: actions/upload-artifact@v4
with:
name: preview-build-pr-${{ github.event.number }}
path: build/docs/gatsby/public
retention-days: 1

deploy-preview:
name: Deploy Preview
needs: test-deploy-24
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: ./.github/workflows/deploy-preview.yaml
with:
pr_number: ${{ github.event.number }}
action: create
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}

remove-preview:
name: Remove Preview
if: github.event_name == 'pull_request' && github.event.action == 'closed'
uses: ./.github/workflows/deploy-preview.yaml
with:
pr_number: ${{ github.event.number }}
action: delete
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion docs/reference/contributors-guide.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributors Guide
# Contributors Guide with cheese and more cheese and more and less cheese

This guide will explain for new and experienced contributors alike how to
propose changes to Ethereum JSON-RPC API.
Expand Down
Loading
Loading