Skip to content

Commit

Permalink
chore(gh-actions): use repository dispatch action (#5653)
Browse files Browse the repository at this point in the history
* chore(gh-actions): use repository dispatch action

* chore(gh-actions): add dispatch for automerge workflow
  • Loading branch information
annawen1 authored Jul 10, 2024
1 parent 248238f commit 17e4276
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: automerge

# This workflow is triggered when any changes are pushed to the release branch and
# when a release candidate or full release has been published in the `release-base` workflow
on:
repository_dispatch:
types: [merge-to-main]
push:
branches: [release/*]
branches: [release/v2*]

concurrency:
group: automerge-${{ github.ref }}
Expand All @@ -14,6 +18,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
ref: ${{ github.event.client_payload.branch }}
- name: Merge to main
uses: devmasx/[email protected]
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ name: Deploy production storybook
# has been successfully completed
on:
workflow_dispatch:
workflow_call:
repository_dispatch:
types: [deploy-latest-storybook]

jobs:
deploy-latest-storybook:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Deploy staging storybook environment from release branch to Github Pages
name: Deploy staging storybook

# Gets triggered every time a change is pushed to the `release/v2*` branch or can be manually triggered
# Gets triggered every time a release candidate has been published from the `release-base` workflow
# or can be manually triggered
on:
workflow_dispatch:
workflow_call:
push:
branches: [release/v2*]
repository_dispatch:
types: [deploy-staging-storybook]

jobs:
deploy-staging-storybook:
Expand All @@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: '0'
ref: ${{ github.event.client_payload.branch }}

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
35 changes: 24 additions & 11 deletions .github/workflows/release-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,27 @@ jobs:
echo "DRY RUN: ${{ env.DRY_RUN }}"
yarn lerna publish --create-release github --preid rc --pre-dist-tag next $(echo "${{ env.DRY_RUN }}")
deploy-staging:
needs: release
# Trigger staging storybook enviroment deployment workflow
if: ${{ github.event.inputs.dry-run == 'false' }}
uses: ./.github/workflows/deploy-staging.yml

deploy-latest:
needs: release
# If full release has been published, trigger the production storybook environment deployment workflow.
if: ${{ (github.event.inputs.dry-run == 'false') && ((github.event.inputs.type == 'full minor release') || (github.event.inputs.type == 'full patch release')) }}
uses: ./.github/workflows/deploy-latest.yml
# After successfully publishing a release candidate, trigger the staging storybook environment deployment workflow.
# Pass in the release branch name to the storybook deployment job so it build off the release branch
- name: Dispatch staging storybook deployment workflow
uses: peter-evans/repository-dispatch@v3
with:
event-type: deploy-staging-storybook
client-payload: '{"branch": "${{ github.ref_name }}"}'

# After successfully publishing a full release, trigger the production storybook environment deployment workflow.
# Pass in the release branch name to the storybook deployment job so it build off the release branch
- name: Dispatch production storybook deployment workflow
if: ${{ (github.event.inputs.type == 'full minor release') || (github.event.inputs.type == 'full patch release') }}
uses: peter-evans/repository-dispatch@v3
with:
event-type: deploy-latest-storybook
client-payload: '{"branch": "${{ github.ref_name }}"}'

# Trigger the `automerge` workflow to the changelog and version bumps generated by Lerna get pushed to `main` branch
- name: Dispatch merge to `main` workflow
uses: peter-evans/repository-dispatch@v3
with:
event-type: merge-to-main
client-payload: '{"branch": "${{ github.ref_name }}"}'

0 comments on commit 17e4276

Please sign in to comment.