Debugging Git workflows #191
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 | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, 'ci skip')" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- uses: pnpm/action-setup@v2.2.2 | ||
with: | ||
run_install: false | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
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@v2 | ||
# - uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: 16 | ||
# - uses: pnpm/action-setup@v2.2.2 | ||
# with: | ||
# run_install: false | ||
# - name: Get pnpm store directory | ||
# id: pnpm-cache | ||
# run: | | ||
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
# - uses: actions/cache@v3 | ||
# name: Setup pnpm cache | ||
# with: | ||
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
# key: ${{ 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@v2 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- uses: pnpm/action-setup@v2.2.2 | ||
with: | ||
run_install: false | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
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@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- uses: pnpm/action-setup@v2.2.2 | ||
with: | ||
run_install: false | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
key: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: pnpm Install | ||
run: pnpm install | ||
- name: Chromatic | ||
run: | | ||
cd packages/react | ||
npx chromatic --project-token ${{ secrets.CHROMATIC_PROJECT_TOKEN }} --exit-zero-on-changes --only-changed | ||
merge: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, 'ci skip') && github.event.pull_request.draft == false" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Check if auto merge possible | ||
id: check | ||
run: | | ||
commit_message=$(git log --format=%B -n 1 $GITHUB_SHA) | ||
pr_title=$(jq --raw-output '.pull_request.title' $GITHUB_EVENT_PATH) | ||
bot_username='github-actions[bot]' | ||
echo "$commit_message" | ||
echo "$pr_title" | ||
echo "$GITHUB_ACTOR" | ||
echo "::set-output name=merge::$(echo "$commit_message" | grep -q 'Version Packages' && echo "$pr_title" | grep -q 'Version Packages' && [ "$bot_username" == "$GITHUB_ACTOR" ])" | ||
- name: Auto merge pull request | ||
if: steps.check.outputs.merge == 'true' | ||
uses: octokit/request-action@v2.x | ||
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 }}" | ||
} |