Merge pull request #14 from OpenUp-LabTakizawa/dependabot/npm_and_yar… #18
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: Node CI | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- "app/**" | |
- "public/**" | |
- "next.config.js" | |
- "package.json" | |
- "postcss.config.js" | |
- "tailwind.config.ts" | |
- "tsconfig.json" | |
- "yarn.lock" | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- "app/**" | |
- "public/**" | |
- "next.config.js" | |
- "package.json" | |
- "postcss.config.js" | |
- "tailwind.config.ts" | |
- "tsconfig.json" | |
- "yarn.lock" | |
workflow_dispatch: | |
jobs: | |
build: | |
name: build-app | |
runs-on: ubuntu-latest | |
outputs: | |
failing_tests: ${{ steps.test.outputs.failing_tests }} | |
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'yarn' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn --frozen-lockfile | |
- name: Build app | |
run: npm run build --if-present | |
- name: Comment on PR | |
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request' | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
comment_tag: test-failures-${{ github.workflow }} | |
message: | | |
❌ @${{ github.actor }} ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ github.workflow }}: | |
${{ steps.test.outputs.failing_tests }} | |
**[View test output](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** | |
<sup>[#${{ github.sha }}](https://github.com/${{ github.repository }}/commits/${{ github.sha }})</sup> | |
- name: Uncomment on PR | |
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request' | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
comment_tag: test-failures-${{ github.workflow }} | |
mode: upsert | |
create_if_not_exists: false | |
message: | | |
✅ test failures on ${{ github.workflow }} have been resolved. | |
<sup>[#${{ github.sha }}](https://github.com/${{ github.repository }}/commits/${{ github.sha }})</sup> |