From 0f8449cf30db1ae8700ece14ce810f66d55dfe16 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:53:29 +0200 Subject: [PATCH 1/7] use action --- .github/workflows/generate-demo-preview.yml | 23 +++++--------------- .github/workflows/generate-documentation.yml | 23 +++++--------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index 06aed95047..d7309f89f6 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -20,34 +20,23 @@ 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: # the id is used by surge to generate the surge url runs-on: ubuntu-20.04 permissions: # surge-preview: PR comments pull-requests: write steps: + - uses: bonitasoft/actions/packages/surge-preview-tools@v1.2.0 + id: surge-preview-tools + with: + surge-token: ${{ secrets.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: Publish Demo preview + if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' id: publish_demo_preview uses: afc163/surge-preview@v1 with: diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index a6e2bc2fb5..6241a5c686 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -30,35 +30,24 @@ on: - 'typedoc.json' jobs: - # inspired from https://github.com/process-analytics/github-actions-playground/pull/23 - check_secrets: - 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] + doc_preview: # the id is used by surge to generate the surge url 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 steps: + - uses: bonitasoft/actions/packages/surge-preview-tools@v1.2.0 + id: surge-preview-tools + with: + surge-token: ${{ secrets.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: Publish preview + if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' id: publish_preview uses: afc163/surge-preview@v1 with: From b9f416c95c96a9817287c9404950db50b3ce723f Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:54:43 +0200 Subject: [PATCH 2/7] simplify wf --- .github/workflows/generate-demo-preview.yml | 3 +-- .github/workflows/generate-documentation.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index d7309f89f6..f98236e6a6 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -20,7 +20,7 @@ on: - 'tsconfig.json' jobs: - demo_preview: # the id is used by surge to generate the surge url + 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 @@ -37,7 +37,6 @@ jobs: if: github.event.action != 'closed' - name: Publish Demo preview if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' - id: publish_demo_preview uses: afc163/surge-preview@v1 with: surge_token: ${{ secrets.SURGE_TOKEN }} diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index 6241a5c686..88b82ca87c 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -30,7 +30,7 @@ on: - 'typedoc.json' jobs: - doc_preview: # the id is used by surge to generate the surge url + doc_preview: # keep unique across jobs using surge preview (preview url and PR comment id) if: github.event_name == 'pull_request' && needs.check_secrets.outputs.is_SURGE_TOKEN_set == 'true' runs-on: ubuntu-20.04 permissions: @@ -48,7 +48,6 @@ jobs: if: github.event.action != 'closed' - name: Publish preview if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' - id: publish_preview uses: afc163/surge-preview@v1 with: surge_token: ${{ secrets.SURGE_TOKEN }} From 0886af8cc21aa15bd52baccf8ab3659682e6a0a5 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:54:50 +0200 Subject: [PATCH 3/7] simplify wf --- .github/workflows/generate-demo-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index f98236e6a6..21abd359cd 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -35,7 +35,7 @@ jobs: - name: Build Setup uses: ./.github/actions/build-setup if: github.event.action != 'closed' - - name: Publish Demo preview + - name: Publish preview if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' uses: afc163/surge-preview@v1 with: From c691048fcdbdd80d210513ba3d46704799c02e80 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 19:04:50 +0200 Subject: [PATCH 4/7] introduce custom surge preview action to remove duplication --- .../actions/custom-surge-preview/action.yml | 38 +++++++++++++++++++ .github/workflows/generate-demo-preview.yml | 23 +++-------- .github/workflows/generate-documentation.yml | 23 +++-------- 3 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 .github/actions/custom-surge-preview/action.yml diff --git a/.github/actions/custom-surge-preview/action.yml b/.github/actions/custom-surge-preview/action.yml new file mode 100644 index 0000000000..02970e97c0 --- /dev/null +++ b/.github/actions/custom-surge-preview/action.yml @@ -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/surge-preview-tools@v1.2.0 + 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 }} diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index 21abd359cd..8990166efb 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -26,23 +26,10 @@ jobs: # surge-preview: PR comments pull-requests: write steps: - - uses: bonitasoft/actions/packages/surge-preview-tools@v1.2.0 - id: surge-preview-tools + - name: surge preview + uses: ./.github/actions/custom-surge-preview with: + build-preview-command: npm run demo + build-preview-dist: build/demo + github-token: ${{ secrets.GITHUB_TOKEN }} surge-token: ${{ secrets.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: Publish preview - if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' - uses: afc163/surge-preview@v1 - with: - surge_token: ${{ secrets.SURGE_TOKEN }} - github_token: ${{ secrets.GITHUB_TOKEN }} - dist: build/demo - failOnError: true - teardown: 'true' - build: | - npm run demo diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index 88b82ca87c..52e1d36218 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -37,26 +37,13 @@ jobs: # surge-preview: PR comments pull-requests: write steps: - - uses: bonitasoft/actions/packages/surge-preview-tools@v1.2.0 - id: surge-preview-tools + - name: surge preview + uses: ./.github/actions/custom-surge-preview with: + build-preview-command: npm run docs + build-preview-dist: build/docs + github-token: ${{ secrets.GITHUB_TOKEN }} surge-token: ${{ secrets.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: Publish preview - if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true' - uses: afc163/surge-preview@v1 - with: - surge_token: ${{ secrets.SURGE_TOKEN }} - github_token: ${{ secrets.GITHUB_TOKEN }} - dist: build/docs - failOnError: true - teardown: 'true' - build: | - npm run docs generate_doc: if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.event.ref == 'refs/heads/master' From 7f12468ff0efc9f943685b12b6e661842ece1a03 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 19:09:56 +0200 Subject: [PATCH 5/7] fix wf --- .github/workflows/generate-demo-preview.yml | 1 + .github/workflows/generate-documentation.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index 8990166efb..027128f031 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -26,6 +26,7 @@ jobs: # surge-preview: PR comments pull-requests: write steps: + - uses: actions/checkout@v3 # access to the local action - name: surge preview uses: ./.github/actions/custom-surge-preview with: diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index 52e1d36218..2c936a25be 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -37,6 +37,7 @@ jobs: # surge-preview: PR comments pull-requests: write steps: + - uses: actions/checkout@v3 # access to the local action - name: surge preview uses: ./.github/actions/custom-surge-preview with: From 050ef61a9364b107c8dc38c1cd38366e66ca81cb Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 19:13:58 +0200 Subject: [PATCH 6/7] Remove extra condition that prevented the doc generation to run --- .github/workflows/generate-documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index 2c936a25be..45adbaee96 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -31,7 +31,7 @@ on: jobs: doc_preview: # keep unique across jobs using surge preview (preview url and PR comment id) - if: github.event_name == 'pull_request' && needs.check_secrets.outputs.is_SURGE_TOKEN_set == 'true' + if: github.event_name == 'pull_request' runs-on: ubuntu-20.04 permissions: # surge-preview: PR comments From 7b14692c2fd82ad5ba33807b7a2d04cd1330c3ce Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Fri, 24 Jun 2022 19:16:58 +0200 Subject: [PATCH 7/7] update comments --- .github/workflows/generate-demo-preview.yml | 3 +-- .github/workflows/generate-documentation.yml | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-demo-preview.yml b/.github/workflows/generate-demo-preview.yml index 027128f031..95c641951a 100644 --- a/.github/workflows/generate-demo-preview.yml +++ b/.github/workflows/generate-demo-preview.yml @@ -23,8 +23,7 @@ jobs: 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 # access to the local action - name: surge preview diff --git a/.github/workflows/generate-documentation.yml b/.github/workflows/generate-documentation.yml index 45adbaee96..4aa283576d 100644 --- a/.github/workflows/generate-documentation.yml +++ b/.github/workflows/generate-documentation.yml @@ -34,8 +34,7 @@ jobs: if: github.event_name == 'pull_request' 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 # access to the local action - name: surge preview @@ -66,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