Skip to content
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

Deploy demo app to GitHub pages automatically #127

Merged
merged 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Deploy demo app to GitHub pages on push
  • Loading branch information
anders-kiaer committed May 14, 2020
commit 5b97fb0ea2ed9a65864cf8da3acdb7301450e075
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