Skip to content
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

chore(ci): add repository dispatch workflow #2442

Merged
merged 1 commit into from
Apr 16, 2024
Merged
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
33 changes: 33 additions & 0 deletions .github/workflows/repository_dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Repository dispatch on main
on:
workflow_dispatch:
push:
branches:
- main

env:
BIOME_WEBSITE_REPO: biomejs/website
BIOME_PUSH_ON_MAIN_EVENT_TYPE: biome-push-on-main-event

jobs:
repository-dispatch:
name: Repository dispatch
runs-on: ubuntu-latest
steps:
- name: Dispatch event on push
if: ${{ github.event_name == 'push' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.BIOME_REPOSITORY_DISPATCH }}
Copy link
Member Author

@Sec-ant Sec-ant Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the PAT token we use and it should be stored as a repository secret and the name should match (I used the name BIOME_REPOSITORY_DISPATCH, we can change the name but they should be kept the same).

repository: ${{ env.BIOME_WEBSITE_REPO }}
event-type: ${{ env.BIOME_PUSH_ON_MAIN_EVENT_TYPE }}
client-payload: '{"event": ${{ toJson(github.event) }}}'
# For testing only, the payload is mocked
- name: Dispatch event on workflow dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.BIOME_REPOSITORY_DISPATCH }}
repository: ${{ env.BIOME_WEBSITE_REPO }}
event-type: ${{ env.BIOME_PUSH_ON_MAIN_EVENT_TYPE }}
client-payload: '{"event": {"head_commit": {"id": "${{ env.GITHUB_SHA }}"}}}'