Skip to content

Commit

Permalink
ci(gh-actions): use repository dispatch event for release
Browse files Browse the repository at this point in the history
  • Loading branch information
duddu committed May 3, 2024
1 parent d875e98 commit 2110a43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ jobs:
trigger-release:
if: github.ref == 'refs/heads/latest'
name: Trigger release on latest
runs-on: ubuntu-latest
needs: build
uses: ./.github/workflows/release.yml
secrets: inherit
permissions:
contents: write
issues: write
pull-requests: write
id-token: write

steps:
- name: Create semantic-release repository dispatch event
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/dispatches \
-f "event_type=semantic-release"
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Release

on:
workflow_call:
repository_dispatch:
types: [semantic-release]
types: [ semantic-release ]

permissions:
contents: read
Expand All @@ -17,6 +16,7 @@ jobs:
issues: write
pull-requests: write
id-token: write
actions: write

steps:
- name: Checkout
Expand All @@ -39,4 +39,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: |
npx semantic-release \
| grep --color -Ei "the next release version is|$" \
|| gh run cancel ${{ github.run_id }} \
&& gh run watch ${{ github.run_id }}

0 comments on commit 2110a43

Please sign in to comment.