-
Notifications
You must be signed in to change notification settings - Fork 12
Add GitHub Actions workflow for deployment #25
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d2c6026
Add GitHub Actions workflow for deployment
PalashChitnavis d588807
Refactor deploy workflow to use template and gh-pages action
PalashChitnavis 8277832
Update deploy workflow to trigger on deploy branch
PalashChitnavis 142e8c6
Update deploy workflow and index template for actor info
PalashChitnavis bd58ccc
Update deploy workflow for main branch and gh-pages
PalashChitnavis ba9ba84
Merge branch 'brian-team:main' into deploy
PalashChitnavis 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
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,85 @@ | ||
| name: Deploy Brian2WASM Simulation to GitHub Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| env: | ||
| SCRIPT: path/to/your/script # 👈 set this | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install pixi | ||
| uses: prefix-dev/setup-pixi@v0.8.0 | ||
| with: | ||
| cache: false | ||
|
|
||
| - name: Install dependencies | ||
| run: pixi install --locked | ||
|
|
||
| - name: Run setup | ||
| run: pixi run setup | ||
|
|
||
| - name: Derive folder paths | ||
| run: | | ||
| FOLDER_PATH="${SCRIPT%.py}" | ||
| FOLDER_NAME=$(basename "$FOLDER_PATH") | ||
| echo "FOLDER_PATH=$FOLDER_PATH" >> $GITHUB_ENV | ||
| echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV | ||
|
|
||
| - name: Generate simulation files | ||
| run: | | ||
| python -m brian2wasm $SCRIPT --no-server | ||
| shell: pixi run bash -e {0} | ||
|
|
||
| - name: Fetch existing gh-pages | ||
| run: | | ||
| rm -rf public | ||
| git clone --branch gh-pages --depth 1 https://github.com/${{ github.repository }} public | ||
|
|
||
| - name: Copy new simulation output | ||
| run: | | ||
| rm -rf public/$FOLDER_NAME | ||
| mkdir -p public/$FOLDER_NAME | ||
| cp $FOLDER_PATH/brian.js \ | ||
| $FOLDER_PATH/index.html \ | ||
| $FOLDER_PATH/wasm_module.js \ | ||
| $FOLDER_PATH/wasm_module.wasm \ | ||
| $FOLDER_PATH/worker.js \ | ||
| public/$FOLDER_NAME/ | ||
|
|
||
| - name: Rebuild main index.html | ||
| run: | | ||
| TEMPLATE="brian2wasm/index_template.html" # 👈 Set this if you want your own template | ||
| cp "$TEMPLATE" public/index.html | ||
|
|
||
| LINKS="" | ||
| for d in public/*/ ; do | ||
| if [ -f "$d/index.html" ]; then | ||
| NAME=$(basename "$d") | ||
| LINKS="$LINKS <li><a href=\"$NAME/\">$NAME</a></li> | ||
| " | ||
| fi | ||
| done | ||
|
|
||
| sed -i "s/{{ACTOR}}/${GITHUB_ACTOR}/g" public/index.html | ||
| sed -i "/{{LINKS}}/{ | ||
| s/{{LINKS}}//g | ||
| r /dev/stdin | ||
| }" public/index.html <<< "$LINKS" | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./public | ||
| publish_branch: gh-pages | ||
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,41 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>{{ACTOR}}'s brian2wasm simulations</title> | ||
| <style> | ||
| body { | ||
| font-family: Arial, sans-serif; | ||
| margin: 40px auto; | ||
| max-width: 700px; | ||
| text-align: center; | ||
| background: #fafafa; | ||
| } | ||
| h1 { | ||
| font-size: 2em; | ||
| margin-bottom: 1em; | ||
| color: #222; | ||
| } | ||
| ul { | ||
| list-style: disc; | ||
| text-align: left; | ||
| display: inline-block; | ||
| font-size: 1.2em; | ||
| line-height: 1.6; | ||
| } | ||
| a { | ||
| text-decoration: none; | ||
| color: #007acc; | ||
| } | ||
| a:hover { | ||
| text-decoration: underline; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h1>{{ACTOR}}'s brian2wasm simulations</h1> | ||
| <ul> | ||
| {{LINKS}} | ||
| </ul> | ||
| </body> | ||
| </html> |
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
Oops, something went wrong.
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.