2022-08-23 16:16:28 -04:00
# .github/workflows/chromatic.yml
# seee https://www.chromatic.com/docs/github-actions
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Workflow name
2022-08-26 17:56:19 -04:00
name : 'Chromatic Pull Request'
2022-08-23 16:16:28 -04:00
2022-08-26 17:56:19 -04:00
# This will allow us to see how the Storybook builds when a PR has been created that has changes in the frontend folder
# NOTE: pull_request_target actions will always run the version of this action on master branch
# you will not see changes in the action behavior until this action's changes have been merged to master.
# This is a security precaution so that PR coming from a fork cannot access a Github secret without a repo
# committer aproving and merging the PR declaring the action safe.
2022-08-23 16:16:28 -04:00
on :
pull_request_target :
2022-08-26 17:56:19 -04:00
2022-08-23 16:16:28 -04:00
# We want this action to run under specific pull request changes
# opened: pull request is created
# synchronize: commit(s) pushed to the pull request
# reopened: closed pull request is reopened
types : [ opened, synchronize, reopened]
2022-08-26 17:56:19 -04:00
# This action will only run if one or more files have changes under the superset-frontend folder
2022-08-23 16:16:28 -04:00
paths :
- "superset-frontend/**"
# List of jobs
jobs :
chromatic-deployment :
# Operating System
runs-on : ubuntu-latest
2022-08-26 19:21:22 -04:00
# define outputs that can be used in the storybook-link-comment job
outputs :
storybookUrl : ${{ steps.chromatic-deploy.outputs.storybookUrl }}
buildUrl : ${{ steps.chromatic-deploy.outputs.buildUrl }}
2022-08-23 16:16:28 -04:00
# Job steps
steps :
2022-08-26 19:21:22 -04:00
- id : chromatic-deploy
2022-08-23 16:16:28 -04:00
- uses : actions/checkout@v1
- name : Install dependencies
run : npm ci
working-directory : superset-frontend
2022-08-26 17:56:19 -04:00
# 👇 Build and publish Storybook to Chromatic
- name : Build and publish Storybook to Chromatic
2022-08-28 17:44:54 -04:00
id : chromatic-deploy
2022-08-23 16:16:28 -04:00
uses : chromaui/action@v1
# Required options for the Chromatic GitHub Action
with :
# 👇 Location of package.json from root of mono-repo
workingDir : superset-frontend
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken : ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
2022-08-26 17:56:19 -04:00
exitZeroOnChanges : true # 👈 Option to prevent the workflow from failing when changes are detected
# Put a comment on the PR with link to latest build of the Storybook for this branch
storybook-link-comment :
# Operating System
runs-on : ubuntu-latest
# job steps
needs : chromatic-deployment
steps :
2022-08-23 19:31:05 -04:00
- name : Echo Storybook build link
uses : actions/github-script@v6
with :
github-token : ${{secrets.GITHUB_TOKEN}}
script : |
github.rest.issues.createComment({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
2022-08-26 19:21:22 -04:00
body : 'Storybook has completed and can be viewed at ${{ needs.chromatic-deployment.outputs.storybookUrl }} Chromatic visual test results can be viewed at ${{ needs.chromatic-deployment.outputs.buildUrl }}'
2022-08-23 19:31:05 -04:00
})