fix the color #4
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: PR Review and Deploy | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm test | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Deploy to GitHub Pages | |
if: github.event.pull_request.state == 'open' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build | |
destination_dir: pr-preview/${{ github.event.pull_request.number }} | |
- name: Comment PR with preview link | |
if: github.event.pull_request.state == 'open' | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Preview deployed to https://${context.repo.owner}.github.io/${context.repo.repo}/pr-preview/${context.issue.number}/` | |
}) | |
merge-and-deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Merge all PRs and deploy via Codespace | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git fetch --depth=2 origin ${{ github.event.pull_request.head.ref }} | |
git merge --no-commit --no-ff origin/${{ github.event.pull_request.head.ref }} | |
git push origin main | |
curl -X POST \ | |
https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows/deploy.yml/dispatches \ | |
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
-H 'Content-Type: application/json' \ | |
-d '{"ref":"main"}' | |
- name: Run site via Codespace | |
uses: github/codespaces-action@v1 | |
with: | |
codespace_name: ${{ github.event.pull_request.number }} | |
codespace_repo: ${{ github.event.repository.name }} | |
codespace_ref: main | |
codespace_command: npm start |