Sanity Studio Dashboard Widget for triggering Github Actions. Implementation is very basic, sending a request to Github via their webhook API, which doesn't make it easy to check status. If request fails, you'll see an error. If successful, it's silent.
TODO:
- User feedback on request status per SiteItem
- Figure out how to track status of the Action, so we can see when the Action is complete
PRs welcome
To get dashboard support in Sanity Studio in general:
sanity install @sanity/dashboard
sanity install dashboard-widget-github-actions
- Implement your own dashboardConfig. In your
sanity.jsonfile, append the following line to thepartsarray:
{
"implements": "part:@sanity/dashboard/config",
"path": "src/dashboardConfig.js"
}- Create the file
src/dashboardConfig.jsand include thegithub-actionswidget config like this:
export default {
widgets: [
{
name: 'github-actions',
options: {
title: 'My Github Actions deploys',
sites: [
{
title: 'Staging',
githubRepo: 'myrepo',
githubRepoOwner: 'myrepoowner',
githubToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
eventType: 'deploy-web-staging',
url: 'https://staging.yoursite.com'
},
{
title: 'Production',
githubRepo: 'myrepo',
githubRepoOwner: 'myrepoowner',
githubToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
eventType: 'deploy-web-production',
url: 'https://www.yoursite.com'
},
]
}
}
]
}title - Override the widget default title
sites[] - Your Github Actions sites to show deploys for
title- Site titlegithubRepo- Name of the Github repo that contains the github actiongithubRepoOwner- Name of the Github repo ownergithubToken- Github personal acces**s token, withrepoprivileges (Docs)eventType- Event type, specified in therepository_dispatchblock of your Github Action workflow file. Example below.eventPayload- JSON string event payload. If specified, it will be passed to the Github Action event
on:
repository_dispatch:
types: deploy-web-stagingTo simulate using your development version as a real module inside a studio, you can do the following:
- Run
npm install && npm linkfrom the root of this repository. - Run
npm run watchto start developing and build the module when changes are made.
With the mono-repo's test-studio:
- Bootstrap the monorepo:
npm run bootstrap - Add
sanity-plugin-dashboard-widget-github-actionswith the current version number topackage.jsonin thetest-studioroot folder (but don't runnpm installafterwards) - Run
npm link sanity-plugin-dashboard-widget-github-actionsinside the mono-repo's root. - Restart the
test-studio
With a regular Sanity Studio:
- Run
npm install - Add
sanity-plugin-dashboard-widget-github-actionswith the current version number topackage.json. - Run
npm link sanity-plugin-dashboard-widget-github-actions - Start the studio
When you are done and have published your new version, you can run npm unlink inside this repo, and npm unlink sanity-plugin-dashboard-widget-github-actions inside the mono-repo or studio to get back to the normal state. Then run npm run bootstrap for the mono-repo or npm install inside the regular studio to use the published version.