Skip to content

feat: simulate "trigger workflows when new version available on npm" #373

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

Merged
merged 1 commit into from
Aug 27, 2024
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
12 changes: 3 additions & 9 deletions .github/actions/notify-PA-repo-of-new-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,23 @@ inputs:
runs:
using: "composite"
steps:
- name: Set VERSION
shell: bash
# in bpmn-visualization-js repo
# run: echo "VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV
# use the action inputs in the playground
run: echo "VERSION=${{ inputs.VERSION }}" >> $GITHUB_ENV
- name: Set CLIENT_PAYLOAD
shell: bash
run: |
if [[ "${{ inputs.BUILD_DEMO_WORKFLOW_ID }}" == '' && "${{ inputs.ARTIFACT_NAME }}" == '' ]]; then
echo "CLIENT_PAYLOAD=$( jq -n -c \
--arg v "${{ env.VERSION }}" \
--arg v "${{ inputs.VERSION }}" \
'{ version: $v }' )" >> $GITHUB_ENV
else
echo "CLIENT_PAYLOAD=$( jq -n -c \
--arg v "${{ env.VERSION }}" \
--arg v "${{ inputs.VERSION }}" \
--arg dr "${{ github.repository }}" \
--arg dwid "${{ inputs.BUILD_DEMO_WORKFLOW_ID }}" \
--arg an "${{ inputs.ARTIFACT_NAME }}" \
'{ version: $v, build_demo_repo: $dr, build_demo_workflow_id: $dwid, artifact_name: $an }' )" >> $GITHUB_ENV
fi
- name: Send Repository Dispatch event
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ inputs.TOKEN }}
repository: process-analytics/${{ inputs.PA_REPOSITORY }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# in bpmn-visualization, the repository_dispatch event is sent after the npm publish is done
# here, to ease the testing, this is done in a dedicated workflow triggered manually
name: Simulate the availability of a new version of an npm package
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true

jobs:
notify:
runs-on: ${{ vars.RUNNER_UBUNTU }}
permissions:
contents: write # to dispatch event
steps:
- name: Send Repository Dispatch event
uses: peter-evans/repository-dispatch@v3
with:
# use the default GITHUB_TOKEN, this is possible because we are dispatching the same repository
event-type: new_version_available_on_npm
client-payload: "{ version: ${{ inputs.version }} }"
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
updateVersion:
runs-on: ${{ vars.RUNNER_UBUNTU }}
env:
VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
ARTIFACT_NAME: ${{ github.event.client_payload.artifact_name || github.event.inputs.artifact_name }}
BUILD_DEMO_WORKFLOW_ID: ${{ github.event.client_payload.build_demo_workflow_id || github.event.inputs.build_demo_workflow_id }}
BUILD_DEMO_REPO: ${{ github.event.client_payload.build_demo_repo || github.event.inputs.build_demo_repo }}
VERSION: ${{ github.event.client_payload.version || inputs.version }}
ARTIFACT_NAME: ${{ github.event.client_payload.artifact_name || inputs.artifact_name }}
BUILD_DEMO_WORKFLOW_ID: ${{ github.event.client_payload.build_demo_workflow_id || inputs.build_demo_workflow_id }}
BUILD_DEMO_REPO: ${{ github.event.client_payload.build_demo_repo || inputs.build_demo_repo }}
steps:
- uses: actions/checkout@v4
- name: Update examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
updateVersion:
runs-on: ${{ vars.RUNNER_UBUNTU }}
env:
VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
VERSION: ${{ github.event.client_payload.version || inputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get the old version of bpmn-visualization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Upload Demo Archive & Trigger Companion Repositories Update

on:
repository_dispatch:
types: [ new_version_available_on_npm ]
workflow_dispatch:
inputs:
version:
Expand All @@ -10,8 +12,12 @@ on:
jobs:
upload_demo_archive:
runs-on: ${{ vars.RUNNER_UBUNTU }}
env:
VERSION: ${{ github.event.client_payload.version || inputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: v${{ env.VERSION }}
- name: Setup node
run: echo "Done"
- name: Install dependencies
Expand All @@ -32,4 +38,4 @@ jobs:
BUILD_DEMO_WORKFLOW_ID: "post-release-upload-demo-archive-and-trigger-companion-repositories-update.yml"
ARTIFACT_NAME: '${{ env.ARTIFACT_NAME }}'
TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
VERSION: ${{ inputs.version }}
VERSION: ${{ env.VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/release-R.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ vars.RUNNER_UBUNTU }}
steps:
- run: |
echo "New version type: ${{ github.event.inputs.type }}"
echo "New version type: ${{ inputs.type }}"

- name: Setup checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-bpmn_visualization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ vars.RUNNER_UBUNTU }}
steps:
- run: |
echo "New version type: ${{ github.event.inputs.type }}"
echo "New version type: ${{ inputs.type }}"
- name: Setup node
uses: actions/setup-node@v4
with:
Expand All @@ -30,6 +30,6 @@ jobs:
run: git checkout master && git pull --tags
- name: Bump Version
run: |
npm version ${{ github.event.inputs.type }} --message "chore(release): %s"
npm version ${{ inputs.type }} --message "chore(release): %s"
- name: Push Version
run: git push && git push --tags
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GitHub pages environment generated by this repository

**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).

- [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
- [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


## Release simulation
Expand All @@ -42,6 +42,8 @@ The [Release of bpmn-visualization](.github/workflows/release-bpmn_visualization
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
and sends a `repository_dispatch` event to simulate notification of companion repositories as done in `bpmn-visualization`.

[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.

**NOTE**: in the bpmn-visualization repository, this workflow is triggered automatically.

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

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


### bpmnVisualizationR
Expand Down
Loading