Skip to content

Commit

Permalink
Merge pull request #412 from chromaui/tech/add-test-workflow_run
Browse files Browse the repository at this point in the history
tech/add-test-workflow_run
  • Loading branch information
ndelangen authored Sep 30, 2021
2 parents 6e3e113 + 2609ef8 commit 487388a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/chromatic-workflow_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Chromatic (workflow_run)"
on:
workflow_run:
workflows:
- "Action"
types:
- completed

jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: yarn
- uses: chromaui/action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: gcaw1ai2dgo
exitZeroOnChanges: true
exitOnceUploaded: true
18 changes: 16 additions & 2 deletions action-src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { error, getInput, setFailed, setOutput } from '@actions/core';
import { error, getInput, setFailed, setOutput, info } from '@actions/core';
import { context } from '@actions/github';
import { readFile } from 'jsonfile';
import pkgUp from 'pkg-up';
Expand Down Expand Up @@ -42,6 +42,17 @@ const getBuildInfo = (event: typeof context) => {
slug: repository.full_name,
};
}
case 'workflow_run': {
const { repository } = event.payload;
// eslint-disable-next-line @typescript-eslint/naming-convention
const { head_sha, head_branch } = event.payload.workflow_run;

return {
sha: head_sha,
branch: head_branch.replace('refs/heads/', ''),
slug: repository.full_name,
};
}
case 'workflow_dispatch': {
const { ref, sha } = event.payload.inputs;

Expand Down Expand Up @@ -186,4 +197,7 @@ async function run() {
process.exit(1);
}
}
run();
run().catch((e) => {
error(e);
setFailed(e.message);
});
6 changes: 3 additions & 3 deletions action-src/register.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Observable from 'zen-observable';
const Observable = require('zen-observable');

global.Observable = Observable;
(await import('any-observable/register'))('global.Observable');
require('any-observable/register')('global.Observable');

await import('./main');
require('./main');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chromatic",
"version": "6.0.0-canary.12",
"version": "6.0.0-canary.13",
"description": "Automate visual testing across browsers. Gather UI feedback. Versioned documentation.",
"keywords": [
"storybook-addon",
Expand Down

0 comments on commit 487388a

Please sign in to comment.