Skip to content

Commit

Permalink
Deploy demo app to GitHub pages on push
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer committed May 14, 2020
1 parent 841a2bf commit 8c52792
Show file tree
Hide file tree
Showing 9 changed files with 1,203 additions and 1,493 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.css
registerServiceWorker.js
registerServiceWorker.js
output.js
31 changes: 28 additions & 3 deletions .github/workflows/webviz-subsurface-components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: webviz-subsurface-components

on:
push:
branches:
- master
pull_request:
branches:
- master
Expand All @@ -15,8 +13,9 @@ on:
- cron: '0 0 * * *'

jobs:

webviz-subsurface-components:
# Run on all events defined above, except pushes which are neither to master nor with a substring [deploy test] in commit message
if: github.event_name != 'push' || github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -78,3 +77,29 @@ jobs:
python -m pip install --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*
- name: 📚 Build demo application
run: npm run build:js-demo

- name: 📚 Update GitHub demo application
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')) && matrix.python-version == '3.6'
run: |
cp ./{index.html,output.css,output.js} ..
git config --local user.email "webviz-github-action"
git config --local user.name "webviz-github-action"
git fetch origin gh-pages
git checkout --track origin/gh-pages
git clean -f -f -d -x
git rm -r *
mv ../{index.html,output.css,output.js} .
git add .
if git diff-index --quiet HEAD; then
echo "No changes in documentation. Skip documentation deploy."
else
git commit -m "Update Github Pages"
git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
webviz_subsurface_components/**/*
!webviz_subsurface_components/__init__.py

output.css
output.js

DESCRIPTION
NAMESPACE
R/
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,25 @@ then:
- Make sure the stylesheets are added to the `_css_dist` dict in
`webviz_subsurface_components/__init__.py` so dash will serve them
automatically when the component suite is requested.
# Automatically upload demo application
This repository has a GitHub workflow which can automatically build and deploy a demo
app with your changes, to GitHub pages.
- On push to your feature branch, in your fork, the workflow will build and deploy a
demo app to your fork's GitHub page, given that your commit message includes the
substring `[deploy test]`.
- On merge to `master` in the main repository, a build + deploy will be done to the
official GitHub page in the main repository.
For this to work in your own fork, you will need to create a branch `gh-pages`
(this you only need to do once). One way of creating this branch is e.g.:
```bash
git checkout --orphan gh-pages
git rm -rf .
git commit --allow-empty
git push origin gh-pages
```

You are encouraged to rebase and squash/fixup unnecessary commits before pull request is merged to `master`.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype>
<html>
<head>
<title>my-dash-component</title>
<title>Demo application of webviz-subsurface-components</title>
</head>
<body>
<div id='root'></div>
<script src="/output.js"></script>
<link rel="stylesheet" type="text/css" href="output.css">
<script src="output.js"></script>
</body>
</html>
Loading

0 comments on commit 8c52792

Please sign in to comment.