Merge pull request #277 from WeGo-Together/somang-feat/group-details #273
This file contains hidden or 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: Save Base Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| save-coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Check if tests exist | |
| id: check-tests | |
| run: | | |
| if find . -path ./node_modules -prune -o -path ./.next -prune -o -type f \( -name "*.test.*" -o -name "*.spec.*" \) -print | grep -q .; then | |
| echo "has_tests=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_tests=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run tests with coverage | |
| id: test | |
| if: steps.check-tests.outputs.has_tests == 'true' | |
| run: pnpm run test:coverage | |
| continue-on-error: true | |
| - name: Fail if tests exist but failed | |
| if: steps.check-tests.outputs.has_tests == 'true' && steps.test.outcome == 'failure' | |
| run: | | |
| echo "::error::Tests failed! Please fix the failing tests." | |
| exit 1 | |
| - name: Check if coverage exists | |
| id: check-coverage | |
| run: | | |
| if [ -f "coverage/coverage-summary.json" ]; then | |
| echo "has_coverage=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_coverage=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload base coverage | |
| if: steps.check-coverage.outputs.has_coverage == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: base-coverage | |
| path: coverage/coverage-summary.json | |
| retention-days: 90 | |
| # GitHub Pages 배포 추가 | |
| - name: Checkout GitHub Pages repo | |
| if: steps.check-coverage.outputs.has_coverage == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: WeGo-Together/WeGo-Together.github.io | |
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| path: gh-pages | |
| - name: Copy coverage report | |
| if: steps.check-coverage.outputs.has_coverage == 'true' | |
| run: | | |
| mkdir -p gh-pages/front/coverage | |
| rm -rf gh-pages/front/coverage/lcov-report | |
| cp -r coverage/lcov-report gh-pages/front/coverage/ | |
| - name: Commit and push to GitHub Pages | |
| if: steps.check-coverage.outputs.has_coverage == 'true' | |
| run: | | |
| cd gh-pages | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add front/coverage/lcov-report | |
| git commit -m "Update coverage report from ${{ github.sha }}" || exit 0 | |
| git push |