-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add GitHub Pages deployment workflow #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
17b00a2
feat: add GitHub Pages deployment workflow
yibeichan 926efa9
fix: use specific commit hash for reproschema-ui
yibeichan e5666a3
fix: slugify protocol name in GitHub URLs
yibeichan 8d1be74
fix: set cancel-in-progress to true for pages deployment
yibeichan 9150aab
fix: use npm ci instead of npm install for CI builds
yibeichan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
{{cookiecutter.protocol_name}}/.github/workflows/deploy-gh-pages.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| name: Deploy to GitHub Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| tags: [ 'v*' ] | ||
| workflow_dispatch: | ||
| inputs: | ||
| ref: | ||
| description: 'Branch, tag, or commit SHA to deploy' | ||
| required: false | ||
| default: 'main' | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: {% raw %}${{ github.event.inputs.ref || github.ref }}{% endraw %} | ||
|
|
||
| - name: Get deployment ref | ||
| id: get-ref | ||
| run: | | ||
| if [ "{% raw %}${{ github.event_name }}{% endraw %}" = "workflow_dispatch" ] && [ -n "{% raw %}${{ github.event.inputs.ref }}{% endraw %}" ]; then | ||
| echo "deploy_ref={% raw %}${{ github.event.inputs.ref }}{% endraw %}" >> $GITHUB_OUTPUT | ||
| elif [ -n "{% raw %}${{ github.ref_name }}{% endraw %}" ]; then | ||
| echo "deploy_ref={% raw %}${{ github.ref_name }}{% endraw %}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "deploy_ref=main" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Clone reproschema-ui | ||
| run: | | ||
| git clone https://github.com/ReproNim/reproschema-ui.git | ||
| cd reproschema-ui | ||
| git checkout master | ||
yibeichan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Build reproschema-ui | ||
| run: | | ||
| cd reproschema-ui | ||
| npm install | ||
yibeichan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| npm run build | ||
|
|
||
| - name: Copy protocol to reproschema-ui | ||
| run: | | ||
| # Copy the entire protocol directory to the reproschema-ui public folder | ||
| cp -r ./{{cookiecutter.__protocol_slug}} reproschema-ui/dist/ | ||
| cp -r ./activities reproschema-ui/dist/ | ||
|
|
||
| # Update the config to point to our protocol | ||
| cat > reproschema-ui/dist/config.js << 'EOF' | ||
| module.exports = { | ||
| /* eslint-disable */ | ||
| 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', | ||
| banner: 'This protocol is deployed from {{cookiecutter.github_org}}/{{cookiecutter.protocol_name}} (ref: {% raw %}${{ steps.get-ref.outputs.deploy_ref }}{% endraw %})', | ||
yibeichan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| startButton: 'Start', | ||
| assetsPublicPath: '/', | ||
| backendServer: null, | ||
| showHelp: true, | ||
| contact: '{{cookiecutter.email}}', | ||
| emailSubject: 'Help with {{cookiecutter.protocol_name}}', | ||
| logoSrc: '{{cookiecutter.__protocol_slug}}/about_the_study.svg', | ||
| auth: { | ||
| on: false, | ||
| }, | ||
| }; | ||
| EOF | ||
|
|
||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v4 | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: 'reproschema-ui/dist' | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| url: {% raw %}${{ steps.deployment.outputs.page_url }}{% endraw %} | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.