公开笔记 #81
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: Deployment | |
on: repository_dispatch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
ssh-key: ${{ secrets.REPOSITORY_PRIVATEKEY }} | |
fetch-depth: 0 | |
# submodules: recursive | |
# persist-credentials: false | |
- name: Initialize and update submodules | |
run: | | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{ secrets.REPOSITORY_PRIVATEKEY }}"; | |
# 初始化子模块 | |
git submodule init | |
# 更新子模块到最新提交 | |
git submodule update --recursive --remote | |
# 修复"GIT仓库clone造成的文件创建和修改时间被调整为部署时间"的脚本 | |
# - name: Restore file modification time | |
# run: | | |
# cd source/_posts/ | |
# git ls-files -z | while read -d '' path; do touch -d "$(git log -1 --format="@%ct" "$path")" "$path"; done | |
- name: npm env | |
run: npm install | |
env: | |
CI: true | |
- name: hexo build | |
run: | | |
npx hexo clean | |
npx hexo generate | |
env: | |
CI: true | |
- name: Deploy | |
uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.ECS_PRIVATEKEY }} | |
ARGS: "-avz --delete" | |
SOURCE: "public/" | |
REMOTE_HOST: ${{ vars.REMOTE_HOST }} | |
REMOTE_USER: ${{ vars.REMOTE_USER }} | |
TARGET: ${{ vars.TARGET }} | |