Skip to content

Commit 17b00a2

Browse files
committed
feat: add GitHub Pages deployment workflow
- Add GitHub Actions workflow to deploy protocol to GitHub Pages - Support automatic deployment on push to main branch or version tags - Enable manual deployment with specific branch/tag/commit - Integrate with reproschema-ui for web-based protocol display - Update README with comprehensive deployment instructions - Use slugified protocol name for valid GitHub Pages URLs The workflow builds reproschema-ui and configures it to serve the protocol, with the deployed version shown in the banner for clarity.
1 parent cca6b2e commit 17b00a2

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: 'Branch, tag, or commit SHA to deploy'
11+
required: false
12+
default: 'main'
13+
type: string
14+
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
ref: {% raw %}${{ github.event.inputs.ref || github.ref }}{% endraw %}
32+
33+
- name: Get deployment ref
34+
id: get-ref
35+
run: |
36+
if [ "{% raw %}${{ github.event_name }}{% endraw %}" = "workflow_dispatch" ] && [ -n "{% raw %}${{ github.event.inputs.ref }}{% endraw %}" ]; then
37+
echo "deploy_ref={% raw %}${{ github.event.inputs.ref }}{% endraw %}" >> $GITHUB_OUTPUT
38+
elif [ -n "{% raw %}${{ github.ref_name }}{% endraw %}" ]; then
39+
echo "deploy_ref={% raw %}${{ github.ref_name }}{% endraw %}" >> $GITHUB_OUTPUT
40+
else
41+
echo "deploy_ref=main" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
49+
- name: Clone reproschema-ui
50+
run: |
51+
git clone https://github.com/ReproNim/reproschema-ui.git
52+
cd reproschema-ui
53+
git checkout master
54+
55+
- name: Build reproschema-ui
56+
run: |
57+
cd reproschema-ui
58+
npm install
59+
npm run build
60+
61+
- name: Copy protocol to reproschema-ui
62+
run: |
63+
# Copy the entire protocol directory to the reproschema-ui public folder
64+
cp -r ./{{cookiecutter.__protocol_slug}} reproschema-ui/dist/
65+
cp -r ./activities reproschema-ui/dist/
66+
67+
# Update the config to point to our protocol
68+
cat > reproschema-ui/dist/config.js << 'EOF'
69+
module.exports = {
70+
/* eslint-disable */
71+
githubSrc: 'https://raw.githubusercontent.com/{{cookiecutter.github_org}}/{{cookiecutter.protocol_name}}/{% raw %}${{ steps.get-ref.outputs.deploy_ref }}{% endraw %}/{{cookiecutter.__protocol_slug}}/{{cookiecutter.__protocol_slug}}_schema',
72+
banner: 'This protocol is deployed from {{cookiecutter.github_org}}/{{cookiecutter.protocol_name}} (ref: {% raw %}${{ steps.get-ref.outputs.deploy_ref }}{% endraw %})',
73+
startButton: 'Start',
74+
assetsPublicPath: '/',
75+
backendServer: null,
76+
showHelp: true,
77+
contact: '{{cookiecutter.email}}',
78+
emailSubject: 'Help with {{cookiecutter.protocol_name}}',
79+
logoSrc: '{{cookiecutter.__protocol_slug}}/about_the_study.svg',
80+
auth: {
81+
on: false,
82+
},
83+
};
84+
EOF
85+
86+
- name: Setup Pages
87+
uses: actions/configure-pages@v4
88+
89+
- name: Upload artifact
90+
uses: actions/upload-pages-artifact@v3
91+
with:
92+
path: 'reproschema-ui/dist'
93+
94+
deploy:
95+
environment:
96+
name: github-pages
97+
url: {% raw %}${{ steps.deployment.outputs.page_url }}{% endraw %}
98+
runs-on: ubuntu-latest
99+
needs: build
100+
steps:
101+
- name: Deploy to GitHub Pages
102+
id: deployment
103+
uses: actions/deploy-pages@v4

{{cookiecutter.protocol_name}}/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@
44

55
## Website
66

7-
[https://{{cookiecutter.github_org}}.github.io/{{cookiecutter.protocol_name}}](https://{{cookiecutter.github_org}}.github.io/{{cookiecutter.protocol_name}})
7+
[https://{{cookiecutter.github_org}}.github.io/{{cookiecutter.protocol_name|slugify}}](https://{{cookiecutter.github_org}}.github.io/{{cookiecutter.protocol_name|slugify}})
8+
9+
## Deployment to GitHub Pages
10+
11+
This repository includes automatic deployment to GitHub Pages. Follow these steps to enable it:
12+
13+
1. **Enable GitHub Pages in your repository:**
14+
- Go to Settings → Pages
15+
- Under "Source", select "GitHub Actions"
16+
- Click Save
17+
18+
2. **The deployment will trigger automatically when:**
19+
- You push to the `main` branch
20+
- You push a tag starting with `v` (e.g., `v1.0.0`)
21+
- You manually trigger the workflow from the Actions tab
22+
23+
3. **Deploy a specific version:**
24+
- Go to the Actions tab
25+
- Select "Deploy to GitHub Pages"
26+
- Click "Run workflow"
27+
- Enter the branch, tag, or commit SHA you want to deploy
28+
- Click "Run workflow"
29+
30+
4. **Access your deployed protocol:**
31+
- Once deployed, visit: `https://{{cookiecutter.github_org}}.github.io/{{cookiecutter.protocol_name|slugify}}`
32+
- The deployment typically takes 2-5 minutes
33+
- The deployed version is shown in the banner
834

935
## Repository Structure
1036

0 commit comments

Comments
 (0)