常规文章更新 #143
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 hexo blog | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.20.4] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Configuration environment | |
env: | |
ACTIONS_DEPLOY_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}} | |
run: | | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
mkdir -p ~/.ssh/ | |
echo "$ACTIONS_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
git config --global user.name "Deepcity" | |
git config --global user.email "f1159472899@163.com" | |
# 暂不清楚为何导致git服务器部署时效果与本地不同,表现为文件消失,功能暂时由脚本代替 | |
# - name: Install dependencies | |
# run: | | |
# npm i -g hexo-cli | |
# npm ci | |
# # 这里可能需要对主题进行npm in | |
# # 对githubPage进行部署 | |
# - name: Deploy hexo | |
# run: | | |
# npm run deploy | |
# 对服务器进行拉取 | |
- name: ssh remove server | |
uses: appleboy/ssh-action@v1.0.0 | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
screen -r clash | |
cd /usr/local/hexo/ | |
git fetch origin | |
git reset --hard origin/gh-pages | |
git clean -fd |