Skip to content

Commit be4a935

Browse files
authored
Merge pull request #11 from ReproNim/feat/github-pages-deployment
feat: add GitHub Pages deployment workflow
2 parents a8e3fd5 + 9150aab commit be4a935

File tree

2 files changed

+131
-1
lines changed

2 files changed

+131
-1
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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: true
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+
# Pin to specific commit for reproducible builds
54+
git checkout 9f7b6b961cdcb516531bbbf1bf1b74648089d04a
55+
56+
- name: Build reproschema-ui
57+
run: |
58+
cd reproschema-ui
59+
npm ci
60+
npm run build
61+
62+
- name: Copy protocol to reproschema-ui
63+
run: |
64+
# Copy the entire protocol directory to the reproschema-ui public folder
65+
cp -r ./{{cookiecutter.__protocol_slug}} reproschema-ui/dist/
66+
cp -r ./activities reproschema-ui/dist/
67+
68+
# Update the config to point to our protocol
69+
cat > reproschema-ui/dist/config.js << 'EOF'
70+
module.exports = {
71+
/* eslint-disable */
72+
githubSrc: 'https://raw.githubusercontent.com/{{cookiecutter.github_org}}/{{cookiecutter.protocol_name|slugify}}/{% raw %}${{ steps.get-ref.outputs.deploy_ref }}{% endraw %}/{{cookiecutter.__protocol_slug}}/{{cookiecutter.__protocol_slug}}_schema',
73+
banner: 'This protocol is deployed from {{cookiecutter.github_org}}/{{cookiecutter.protocol_name|slugify}} (ref: {% raw %}${{ steps.get-ref.outputs.deploy_ref }}{% endraw %})',
74+
startButton: 'Start',
75+
assetsPublicPath: '/',
76+
backendServer: null,
77+
showHelp: true,
78+
contact: '{{cookiecutter.email}}',
79+
emailSubject: 'Help with {{cookiecutter.protocol_name}}',
80+
logoSrc: '{{cookiecutter.__protocol_slug}}/about_the_study.svg',
81+
auth: {
82+
on: false,
83+
},
84+
};
85+
EOF
86+
87+
- name: Setup Pages
88+
uses: actions/configure-pages@v4
89+
90+
- name: Upload artifact
91+
uses: actions/upload-pages-artifact@v3
92+
with:
93+
path: 'reproschema-ui/dist'
94+
95+
deploy:
96+
environment:
97+
name: github-pages
98+
url: {% raw %}${{ steps.deployment.outputs.page_url }}{% endraw %}
99+
runs-on: ubuntu-latest
100+
needs: build
101+
steps:
102+
- name: Deploy to GitHub Pages
103+
id: deployment
104+
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)