Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
38 changes: 38 additions & 0 deletions .github/actions/custom-surge-preview/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Custom surge preview'
description: 'Simplify usage of surge-preview'
inputs:
build-preview-command:
description: 'The command to build the preview'
required: true
build-preview-dist:
description: 'The dist folder deployed to surge.sh'
required: true
github-token:
description: 'A token with `pull-requests: write` to let the surge-preview action create comments on pull requests'
required: true
surge-token:
description: 'A surge token to manage the deployment'
required: true

runs:
using: 'composite'
steps:
- uses: bonitasoft/actions/packages/[email protected]
id: surge-preview-tools
with:
surge-token: ${{ inputs.surge-token }}
- uses: actions/checkout@v3
if: github.event.action != 'closed'
- name: Build Setup
uses: ./.github/actions/build-setup
if: github.event.action != 'closed'
- name: Manage surge preview
if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
uses: afc163/surge-preview@v1
with:
surge_token: ${{ inputs.surge-token }}
github_token: ${{ inputs.github-token }}
dist: ${{ inputs.build-preview-dist }}
failOnError: true
teardown: 'true'
build: ${{ inputs.build-preview-command }}
43 changes: 9 additions & 34 deletions .github/workflows/generate-demo-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,16 @@ on:
- 'tsconfig.json'

jobs:
# inspired from https://github.com/process-analytics/github-actions-playground/pull/23
check_secrets:
runs-on: ubuntu-20.04
outputs:
is_SURGE_TOKEN_set: ${{ steps.secret_availability.outputs.is_SURGE_TOKEN_set }}
steps:
- name: Compute secrets availability
id: secret_availability
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
run: |
echo "is_SURGE_TOKEN_set: ${{ env.SURGE_TOKEN != '' }}"
echo "::set-output name=is_SURGE_TOKEN_set::${{ env.SURGE_TOKEN != '' }}"

demo_preview:
needs: [check_secrets]
if: needs.check_secrets.outputs.is_SURGE_TOKEN_set == 'true'
demo_preview: # keep unique across jobs using surge preview (preview url and PR comment id)
runs-on: ubuntu-20.04
permissions:
# surge-preview: PR comments
pull-requests: write
pull-requests: write # surge-preview: PR comments
steps:
- uses: actions/checkout@v3
if: github.event.action != 'closed'
- name: Build Setup
uses: ./.github/actions/build-setup
if: github.event.action != 'closed'
- name: Publish Demo preview
id: publish_demo_preview
uses: afc163/surge-preview@v1
- uses: actions/checkout@v3 # access to the local action
- name: surge preview
uses: ./.github/actions/custom-surge-preview
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dist: build/demo
failOnError: true
teardown: 'true'
build: |
npm run demo
build-preview-command: npm run demo
build-preview-dist: build/demo
github-token: ${{ secrets.GITHUB_TOKEN }}
surge-token: ${{ secrets.SURGE_TOKEN }}
46 changes: 10 additions & 36 deletions .github/workflows/generate-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,20 @@ on:
- 'typedoc.json'

jobs:
# inspired from https://github.com/process-analytics/github-actions-playground/pull/23
check_secrets:
doc_preview: # keep unique across jobs using surge preview (preview url and PR comment id)
if: github.event_name == 'pull_request'
runs-on: ubuntu-20.04
outputs:
is_SURGE_TOKEN_set: ${{ steps.secret_availability.outputs.is_SURGE_TOKEN_set }}
steps:
- name: Compute secrets availability
id: secret_availability
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
run: |
echo "is_SURGE_TOKEN_set: ${{ env.SURGE_TOKEN != '' }}"
echo "::set-output name=is_SURGE_TOKEN_set::${{ env.SURGE_TOKEN != '' }}"

doc_preview:
needs: [check_secrets]
if: github.event_name == 'pull_request' && needs.check_secrets.outputs.is_SURGE_TOKEN_set == 'true'
runs-on: ubuntu-20.04
permissions:
# surge-preview: PR comments
pull-requests: write
pull-requests: write # surge-preview: PR comments
steps:
- uses: actions/checkout@v3
if: github.event.action != 'closed'
- name: Build Setup
uses: ./.github/actions/build-setup
if: github.event.action != 'closed'
- name: Publish preview
id: publish_preview
uses: afc163/surge-preview@v1
- uses: actions/checkout@v3 # access to the local action
- name: surge preview
uses: ./.github/actions/custom-surge-preview
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dist: build/docs
failOnError: true
teardown: 'true'
build: |
npm run docs
build-preview-command: npm run docs
build-preview-dist: build/docs
github-token: ${{ secrets.GITHUB_TOKEN }}
surge-token: ${{ secrets.SURGE_TOKEN }}

generate_doc:
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.event.ref == 'refs/heads/master'
Expand All @@ -90,8 +65,7 @@ jobs:
runs-on: ubuntu-20.04
needs: generate_doc
permissions:
# Push to gh-pages
contents: write
contents: write # Push to gh-pages
steps:
- name: Download
uses: actions/download-artifact@v3
Expand Down