Skip to content

Commit 5c67a88

Browse files
authored
feat: simulate "trigger workflows when new version available on npm" (#373)
This simulates what we are achieving in the `bpmn-visualization` repository. Introduce a workflow that sends a repository-dispatch event which triggers the workflow that builds the bpmn-visualization demo for the repository of examples. Additional refactoring - simplify the retrieval of inputs of a workflow_dispatch - bump peter-evans/repository-dispatch from v2 to v3 (mainly to enforce run with Node20) in the shared action
1 parent c3de6eb commit 5c67a88

8 files changed

+44
-20
lines changed

.github/actions/notify-PA-repo-of-new-version/action.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,23 @@ inputs:
2525
runs:
2626
using: "composite"
2727
steps:
28-
- name: Set VERSION
29-
shell: bash
30-
# in bpmn-visualization-js repo
31-
# run: echo "VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV
32-
# use the action inputs in the playground
33-
run: echo "VERSION=${{ inputs.VERSION }}" >> $GITHUB_ENV
3428
- name: Set CLIENT_PAYLOAD
3529
shell: bash
3630
run: |
3731
if [[ "${{ inputs.BUILD_DEMO_WORKFLOW_ID }}" == '' && "${{ inputs.ARTIFACT_NAME }}" == '' ]]; then
3832
echo "CLIENT_PAYLOAD=$( jq -n -c \
39-
--arg v "${{ env.VERSION }}" \
33+
--arg v "${{ inputs.VERSION }}" \
4034
'{ version: $v }' )" >> $GITHUB_ENV
4135
else
4236
echo "CLIENT_PAYLOAD=$( jq -n -c \
43-
--arg v "${{ env.VERSION }}" \
37+
--arg v "${{ inputs.VERSION }}" \
4438
--arg dr "${{ github.repository }}" \
4539
--arg dwid "${{ inputs.BUILD_DEMO_WORKFLOW_ID }}" \
4640
--arg an "${{ inputs.ARTIFACT_NAME }}" \
4741
'{ version: $v, build_demo_repo: $dr, build_demo_workflow_id: $dwid, artifact_name: $an }' )" >> $GITHUB_ENV
4842
fi
4943
- name: Send Repository Dispatch event
50-
uses: peter-evans/repository-dispatch@v2
44+
uses: peter-evans/repository-dispatch@v3
5145
with:
5246
token: ${{ inputs.TOKEN }}
5347
repository: process-analytics/${{ inputs.PA_REPOSITORY }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# in bpmn-visualization, the repository_dispatch event is sent after the npm publish is done
2+
# here, to ease the testing, this is done in a dedicated workflow triggered manually
3+
name: Simulate the availability of a new version of an npm package
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version'
9+
required: true
10+
11+
jobs:
12+
notify:
13+
runs-on: ${{ vars.RUNNER_UBUNTU }}
14+
permissions:
15+
contents: write # to dispatch event
16+
steps:
17+
- name: Send Repository Dispatch event
18+
uses: peter-evans/repository-dispatch@v3
19+
with:
20+
# use the default GITHUB_TOKEN, this is possible because we are dispatching the same repository
21+
event-type: new_version_available_on_npm
22+
client-payload: "{ version: ${{ inputs.version }} }"

.github/workflows/post-release-update_bpmn_visualization_version_in_Examples_repo.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
updateVersion:
2525
runs-on: ${{ vars.RUNNER_UBUNTU }}
2626
env:
27-
VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
28-
ARTIFACT_NAME: ${{ github.event.client_payload.artifact_name || github.event.inputs.artifact_name }}
29-
BUILD_DEMO_WORKFLOW_ID: ${{ github.event.client_payload.build_demo_workflow_id || github.event.inputs.build_demo_workflow_id }}
30-
BUILD_DEMO_REPO: ${{ github.event.client_payload.build_demo_repo || github.event.inputs.build_demo_repo }}
27+
VERSION: ${{ github.event.client_payload.version || inputs.version }}
28+
ARTIFACT_NAME: ${{ github.event.client_payload.artifact_name || inputs.artifact_name }}
29+
BUILD_DEMO_WORKFLOW_ID: ${{ github.event.client_payload.build_demo_workflow_id || inputs.build_demo_workflow_id }}
30+
BUILD_DEMO_REPO: ${{ github.event.client_payload.build_demo_repo || inputs.build_demo_repo }}
3131
steps:
3232
- uses: actions/checkout@v4
3333
- name: Update examples

.github/workflows/post-release-update_bpmn_visualization_version_in_R_repo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
updateVersion:
1313
runs-on: ${{ vars.RUNNER_UBUNTU }}
1414
env:
15-
VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
15+
VERSION: ${{ github.event.client_payload.version || inputs.version }}
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Get the old version of bpmn-visualization

.github/workflows/post-release-upload-demo-archive-and-trigger-companion-repositories-update.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Upload Demo Archive & Trigger Companion Repositories Update
22

33
on:
4+
repository_dispatch:
5+
types: [ new_version_available_on_npm ]
46
workflow_dispatch:
57
inputs:
68
version:
@@ -10,8 +12,12 @@ on:
1012
jobs:
1113
upload_demo_archive:
1214
runs-on: ${{ vars.RUNNER_UBUNTU }}
15+
env:
16+
VERSION: ${{ github.event.client_payload.version || inputs.version }}
1317
steps:
1418
- uses: actions/checkout@v4
19+
with:
20+
ref: v${{ env.VERSION }}
1521
- name: Setup node
1622
run: echo "Done"
1723
- name: Install dependencies
@@ -32,4 +38,4 @@ jobs:
3238
BUILD_DEMO_WORKFLOW_ID: "post-release-upload-demo-archive-and-trigger-companion-repositories-update.yml"
3339
ARTIFACT_NAME: '${{ env.ARTIFACT_NAME }}'
3440
TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
35-
VERSION: ${{ inputs.version }}
41+
VERSION: ${{ env.VERSION }}

.github/workflows/release-R.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ vars.RUNNER_UBUNTU }}
1313
steps:
1414
- run: |
15-
echo "New version type: ${{ github.event.inputs.type }}"
15+
echo "New version type: ${{ inputs.type }}"
1616
1717
- name: Setup checkout
1818
uses: actions/checkout@v4

.github/workflows/release-bpmn_visualization.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ vars.RUNNER_UBUNTU }}
1313
steps:
1414
- run: |
15-
echo "New version type: ${{ github.event.inputs.type }}"
15+
echo "New version type: ${{ inputs.type }}"
1616
- name: Setup node
1717
uses: actions/setup-node@v4
1818
with:
@@ -30,6 +30,6 @@ jobs:
3030
run: git checkout master && git pull --tags
3131
- name: Bump Version
3232
run: |
33-
npm version ${{ github.event.inputs.type }} --message "chore(release): %s"
33+
npm version ${{ inputs.type }} --message "chore(release): %s"
3434
- name: Push Version
3535
run: git push && git push --tags

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ GitHub pages environment generated by this repository
2828

2929
**TODO they are going to move in another repositories as they are not playground workflows.** See [#229](https://github.com/process-analytics/github-actions-playground/issues/229).
3030

31-
- [List installed softwares on GitHub runners](list-installed-packages-and-tools.yml): see [#78](https://github.com/process-analytics/github-actions-playground/pull/78) for rationale
31+
- [List installed software on GitHub runners](.github/workflows/list-installed-packages-and-tools.yml): see [#78](https://github.com/process-analytics/github-actions-playground/pull/78) for rationale
3232

3333

3434
## Release simulation
@@ -42,6 +42,8 @@ The [Release of bpmn-visualization](.github/workflows/release-bpmn_visualization
4242
Then, you can run a [dedicated workflow](.github/workflows/post-release-upload-demo-archive-and-trigger-companion-repositories-update.yml) builds a fake demo, attaches it as an artifact
4343
and sends a `repository_dispatch` event to simulate notification of companion repositories as done in `bpmn-visualization`.
4444

45+
[Another workflow](.github/workflows/post-release-simulate-new-version-available-on-npm.yml) can be triggered manually to simulate the availability of a new version of the npm package. It will send a `repository_dispatch` event that will trigger the workflow mentioned above.
46+
4547
**NOTE**: in the bpmn-visualization repository, this workflow is triggered automatically.
4648

4749
The event is received by the repository which triggers workflows (simulate what happen in companion repositories)
@@ -52,7 +54,7 @@ The event is received by the repository which triggers workflows (simulate what
5254
### bpmn-visualization-examples
5355

5456
When a tag is pushed in this repository, a new GitHub draft release is created as it is done in bpmn-visualization-examples.
55-
See the related [worfklow](.github/workflows/post-release-create-gh-release_Examples_repo.yml).
57+
See the related [workflow](.github/workflows/post-release-create-gh-release_Examples_repo.yml).
5658

5759

5860
### bpmnVisualizationR

0 commit comments

Comments
 (0)