ci: try ci #2215
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: LeetCode Trip | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install Pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
- name: Execute unit tests | |
run: pnpm run test | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./lcov.info,./clover.xml | |
directory: ./coverage/ | |
verbose: true | |
- name: Slack Notification on Success at Testing Stage | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Test Success | |
SLACK_COLOR: good | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
- name: Slack Notification on Failure at Testing Stage | |
uses: rtCamp/action-slack-notify@v2 | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Test Failure | |
SLACK_COLOR: danger | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
deployment: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install Pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
- name: Compilation | |
run: pnpm run build | |
- name: Copy file via ssh key | |
uses: appleboy/scp-action@v0.1.4 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSH_KEY }} | |
source: 'build' | |
target: '/var/www/leetcode-trip' | |
- uses: actions/checkout@v4 | |
- name: Algoria DocSearch Crawler | |
uses: darrenjennings/algolia-docsearch-action@master | |
with: | |
algolia_application_id: ${{ secrets.ALGORIA_APP_ID }} | |
algolia_api_key: ${{ secrets.ALGORIA_API_KEY }} | |
file: './algolia-config.json' | |
- name: Slack Notification on Success at Deployment Stage | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Deploy Success | |
SLACK_COLOR: good | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
- name: Slack Notification on Failure at Deployment Stage | |
uses: rtCamp/action-slack-notify@v2 | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Deploy Failure | |
SLACK_COLOR: danger | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' |