Skip to content

Commit

Permalink
build: publish to GitHub pages when pushing to main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
divdavem committed Jul 28, 2023
1 parent d3a45e9 commit 5f1210a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
description: 'Whether to publish the documentation on gh-pages'
type: boolean
default: false
docPath:
description: 'If version is empty, path in which the documentation on gh-pages should be published.'
type: string
default: ''
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -49,11 +53,6 @@ jobs:
with:
file: core/coverage/lcov.info
flags: unit
- if: inputs.docPublish
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- run: ./scripts/npmPublish.sh --dry-run
- if: inputs.version != '' && inputs.npmPublish
run: |
Expand All @@ -62,14 +61,24 @@ jobs:
git push origin v${{ inputs.version }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- if: inputs.version != '' && inputs.docPublish
- if: inputs.docPublish && (inputs.version != '' || inputs.docPath != '')
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- if: inputs.docPublish && (inputs.version != '' || inputs.docPath != '')
env:
VERSION: ${{ inputs.version }}
working-directory: gh-pages
run: |
rm -rf v${VERSION%.*}
cp -a ../demo/dist v${VERSION%.*}
if [ -n "$VERSION" ]; then
export DOC_PATH="v${VERSION%.*}"
else
export DOC_PATH="${{ inputs.docPath }}"
fi
rm -rf "$DOC_PATH"
cp -a ../demo/dist "$DOC_PATH"
rm -f latest && ln -s v$(npx semver v* | tail -1) latest
git add .
git commit --allow-empty -a -m "v${{ inputs.version }} from ${{ github.sha }}"
git commit --allow-empty -a -m "$DOC_PATH from ${{ github.sha }}"
git push origin gh-pages
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
needs: e2e-tests
uses: './.github/workflows/build.yml'
with:
docPath: main
docPublish: true
e2e-tests:
uses: './.github/workflows/e2e-tests.yml'
9 changes: 9 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pr
on:
pull_request:
branches: [main]
jobs:
build:
uses: './.github/workflows/build.yml'
e2e-tests:
uses: './.github/workflows/e2e-tests.yml'

0 comments on commit 5f1210a

Please sign in to comment.