cal.pub0.org/.github/workflows/pr.yml

145 lines
4.6 KiB
YAML
Raw Normal View History

2023-02-18 02:13:25 +00:00
name: PR Update
on:
2023-02-18 03:12:19 +00:00
push:
2023-02-18 02:13:25 +00:00
pull_request:
workflow_dispatch:
env:
2023-02-18 02:57:07 +00:00
node_version: ${{ secrets.NODE_VERSION }}
2023-02-18 03:16:27 +00:00
# pr_id: ${{ github.event.number }}
pr_id: 1
2023-02-18 02:13:25 +00:00
concurrency:
group: pr-update-${{ github.event.number }}
cancel-in-progress: true
jobs:
setup:
name: Yarn install & cache
2023-02-18 03:12:50 +00:00
uses: ./.github/workflows/yarn-install.yml
2023-02-18 02:13:25 +00:00
secrets:
2023-02-18 02:57:07 +00:00
node_version: ${{ secrets.NODE_VERSION }}
2023-02-18 03:12:06 +00:00
2023-02-20 23:02:05 +00:00
type-check:
2023-02-20 23:00:49 +00:00
name: Type check
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn-install
with:
node_version: ${{ secrets.NODE_VERSION }}
2023-02-21 03:05:54 +00:00
- run: yarn prisma generate
2023-02-20 23:00:49 +00:00
- run: yarn type-check
2023-02-18 02:13:25 +00:00
lint:
name: Linters
runs-on: ubuntu-latest
needs: setup
steps:
2023-02-20 22:04:03 +00:00
- uses: actions/checkout@v3
2023-02-21 02:37:19 +00:00
- uses: ./.github/actions/yarn-install
2023-02-20 22:04:03 +00:00
with:
node_version: ${{ secrets.NODE_VERSION }}
2023-02-18 19:09:58 +00:00
- run: yarn lint
2023-02-20 22:04:03 +00:00
2023-02-18 02:13:25 +00:00
build:
name: Production build
needs: setup
2023-02-18 02:55:47 +00:00
uses: ./.github/workflows/production-build.yml
2023-02-18 02:13:25 +00:00
secrets:
2023-02-18 03:12:06 +00:00
node_version: ${{ secrets.NODE_VERSION }}
2023-02-18 02:13:25 +00:00
e2e-test:
name: E2E tests
2023-02-18 03:12:06 +00:00
needs: [lint, build]
2023-02-18 22:32:16 +00:00
uses: ./.github/workflows/yarn-e2e.yml
secrets:
node_version: ${{ secrets.NODE_VERSION }}
2023-02-18 17:11:02 +00:00
analyze:
runs-on: ubuntu-latest
needs: build
2023-02-18 17:39:55 +00:00
defaults:
run:
# change this if your nextjs app does not live at the root of the repo
working-directory: ./apps/web/
2023-02-18 17:11:02 +00:00
steps:
2023-02-20 21:53:43 +00:00
- uses: actions/checkout@v3
2023-02-20 21:51:46 +00:00
- uses: ./.github/actions/yarn-install
2023-02-18 19:09:58 +00:00
with:
2023-02-20 21:51:46 +00:00
node_version: ${{ env.node_version }}
2023-02-20 23:36:39 +00:00
- uses: ./.github/actions/cache-build
2023-02-18 19:09:58 +00:00
with:
2023-02-20 23:36:39 +00:00
node_version: ${{ env.node_version }}
2023-02-18 17:11:02 +00:00
# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle
run: npx -p nextjs-bundle-analysis report
- name: Upload bundle
uses: actions/upload-artifact@v2
with:
name: bundle
path: apps/web/.next/analyze/__bundle_analysis.json
- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with:
workflow: nextjs-bundle-analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: apps/web/.next/analyze/base
# And here's the second place - this runs after we have both the current and
# base branch bundle stats, and will compare them to determine what changed.
# There are two configurable arguments that come from package.json:
#
# - budget: optional, set a budget (bytes) against which size changes are measured
# it's set to 350kb here by default, as informed by the following piece:
# https://infrequently.org/2021/03/the-performance-inequality-gap/
#
# - red-status-percentage: sets the percent size increase where you get a red
# status indicator, defaults to 20%
#
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# entry in your package.json file.
- name: Compare with base branch bundle
if: success() && github.event.number
2023-02-18 17:39:55 +00:00
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
2023-02-18 17:11:02 +00:00
- name: Get comment body
id: get-comment-body
if: success() && github.event.number
run: |
2023-02-18 17:39:55 +00:00
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
2023-02-18 17:11:02 +00:00
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Find Comment
uses: peter-evans/find-comment@v1
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: "<!-- __NEXTJS_BUNDLE -->"
- name: Create Comment
uses: peter-evans/create-or-update-comment@v1.4.4
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
- name: Update Comment
uses: peter-evans/create-or-update-comment@v1.4.4
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace