ACM迎新赛入口开放 #2
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: Deploy | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 8 | |
run_install: false | |
- name: Install npm dependencies | |
run: pnpm i | |
- name: Set up back-end url | |
env: | |
BACKEND_URL: ${{ secrets.BACKEND_URL }} | |
run: | | |
sed -i "s|REPLACE_ME|$BACKEND_URL|g" src/utils/const.ts | |
- name: Build | |
run: pnpm run build | |
- name: Setup Deploy Private Key | |
env: | |
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$DEPLOY_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan blog.zhullyb.top >> ~/.ssh/known_hosts | |
- name: Install rsync | |
run: | | |
sudo apt-get install rsync | |
- name: Deploy | |
id: deployment | |
run: | | |
rsync -avz --delete dist/ root@blog.zhullyb.top:/var/www/jh/ | |