Version Packages #291
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Pull Requests | |
on: | |
pull_request: | |
branches: | |
- master | |
concurrency: | |
group: ${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
with: | |
run_install: false | |
- name: Get pnpm store cache directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Lint | |
run: pnpm run lint | |
# audit: | |
# runs-on: ubuntu-latest | |
# if: "!contains(github.event.head_commit.message, 'ci skip')" | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - uses: actions/setup-node@v3 | |
# with: | |
# node-version: 16 | |
# - uses: pnpm/action-setup@v2 | |
# with: | |
# run_install: false | |
# - name: Get pnpm store cache directory | |
# shell: bash | |
# run: | | |
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
# - uses: actions/cache@v3 | |
# name: Setup pnpm cache | |
# with: | |
# path: ${{ env.STORE_PATH }} | |
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
# restore-keys: | | |
# ${{ runner.os }}-pnpm-store- | |
# - name: pnpm Install | |
# run: pnpm install | |
# - name: Run Audit | |
# run: pnpm audit --production --audit-level moderate | |
unit: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
with: | |
run_install: false | |
- name: Get pnpm store cache directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Run Unit Tests | |
run: pnpm test | |
chromatic: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip') && github.event.pull_request.draft == false" | |
needs: [lint, unit] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
with: | |
run_install: false | |
- name: Get pnpm store cache directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Chromatic | |
uses: chromaui/[email protected] | |
with: | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
workingDir: packages/react | |
onlyChanged: true | |
exitZeroOnChanges: true | |
exitOnceUploaded: true | |
merge: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip') && github.event.pull_request.draft == false" | |
needs: [chromatic] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check if auto merge possible | |
id: check | |
run: | | |
pr_title=$(jq --raw-output '.pull_request.title' $GITHUB_EVENT_PATH) | |
bot_username='IPWright83' | |
echo "$pr_title" | |
echo "$GITHUB_ACTOR" | |
auto_merge=$(echo "$pr_title" | grep -q 'Version Packages' && [ "$bot_username" == "$GITHUB_ACTOR" ] && echo "true" || echo "false") | |
echo "$auto_merge" | |
echo "::set-output name=merge::$auto_merge" | |
- name: Auto merge pull request | |
if: steps.check.outputs.merge == 'true' | |
uses: octokit/[email protected] | |
with: | |
route: PUT /repos/IPWright83/chart-io/pulls/${{ github.event.pull_request.number }}/merge | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
{ | |
"commit_title": "Auto merge", | |
"commit_message": "Automatically merged", | |
"sha": "${{ github.event.pull_request.head.sha }}" | |
} | |
- name: Trigger push-to-master workflow | |
if: steps.check.outputs.merge == 'true' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'push-to-master.yml', | |
ref: 'master', | |
}) |