-
Notifications
You must be signed in to change notification settings - Fork 10
4. Extras
Figure: Postman configuration for GitHub Dispatch trigger
- Set the
POST URL
https://api.github.com/repos/_Your_GITHUB_ACCOUNT_/Northwind.People/dispatches - Add the additional headers
Accept = application/vnd.github.everest-preview+json
Authorization = token <GitHubToken>
- Ensure the original
Accept
header is disabled. Figure: JSON payload required for the automated profile generation - Create the payload for the new profile
- Send the post request to GitHub
-
Create a new secret on your Northwind.People fork called
ACCESS_TOKEN
.
The value of this secret will be your GitHub username and Personal Access Token for exampleusername:access_token
.
This will be used to allow dispatch commands to be sent to your SSW.People fork. -
Update the build and deployment workflow on your SSW.People fork.
Add the following code snippet to the on trigger of your existing build and deploy workflow.
repository_dispatch:
types: [build_and_deploy]
Your on trigger will now look something like this.
on:
repository_dispatch:
types: [build_and_deploy]
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
If there is a filter on the events that allow the build to run, you will need to add the following.
github.event.action == 'build_and_deploy' ||
Here is an example of it with the Azure Static Web App build and deploy workflow.
jobs:
build_and_deploy_job:
if: github.event.action == 'build_and_deploy' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
- Create the trigger workflow on the Northwind.People fork.
Create a new workflow with the following code, replacing<USERNAME>
with your GitHub username.
name: Trigger CI/CD when updating the repository
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Run a multi-line script
run: |
curl -X POST https://api.github.com/repos/<USERNAME>/SSW.People/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.ACCESS_TOKEN }} \
--data '{"event_type": "build_and_deploy", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
- Edit a file on the Northwind.People fork.
To test everything works, update a file on your Northwind.People fork.
Once the change has been pushed to your forks main branch, the workflow should run and generate a build on your SSW.People fork.
If you need help to adapt SSW.People to your need (data source, design, new widgets for the profile page), contact SSW