@jacdx/sanity-plugin-dashboard-widget-github-actions v0.1.1
Sanity Dashboard Widget: Github Actions
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:
1. User feedback on request status per SiteItem
2. Figure out how to track status of the Action, so we can see when the Action is complete
PRs welcome
Installing
Install the dashboard plugin
To get dashboard support in Sanity Studio in general:
sanity install @sanity/dashboard
Install the Github Actions widget plugin
sanity install dashboard-widget-github-actions
Configuring
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' }, ] } } ] }
Widget options
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
Github Action workflow: event type example
on:
repository_dispatch:
types: deploy-web-stagingDeveloping on this module
To 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.
Displaying your development version inside a studio
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.