Update index.html #24
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: 同步至 Origin Server | |
#此文件用于自动同步至 Lighthouse Server | |
#请勿修改或删除!!! | |
#BY:ZhuMeng | |
on: | |
push: | |
branches: | |
- main | |
#手动触发 | |
workflow_dispatch: | |
jobs: | |
build: | |
# runs-on 指定job任务运行所需要的虚拟机环境(必填字段) | |
runs-on: ubuntu-latest | |
steps: | |
# 获取源码 | |
- name: 迁出代码 | |
# 使用action库 actions/checkout获取源码 | |
uses: actions/checkout@master | |
- name: 获取提交版本号 | |
id: get_version | |
run: | | |
version=$(git rev-parse --short HEAD) | |
echo "VERSION=$version" >> $GITHUB_ENV | |
echo "Latest commit version: $version" | |
- name: 查询所有 HTML 文件 | |
run: | | |
find . -type f -name "*.html" > html_files.txt | |
cat html_files.txt # 输出查找到的 HTML 文件列表 | |
- name: 更新 HTML 中的版本号 | |
run: | | |
version=${{ env.VERSION }} | |
while IFS= read -r file; do | |
sed -i "s/{{VERSION}}/$version/g" "$file" | |
echo "Updated version in $file" | |
done < html_files.txt | |
- name: 输出修改后的 HTML 文件列表 | |
run: | | |
cat html_files.txt # 输出修改后的 HTML 文件列表 | |
# 上传 | |
- name: 发布到腾讯云 | |
uses: easingthemes/ssh-deploy@main | |
env: | |
# 私钥 | |
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
# scp参数 | |
ARGS: '-rltgoDzvO' | |
# 排除文件 | |
EXCLUDE: '/.git/, /.github/' | |
# 源目录 | |
SOURCE: '' | |
# 服务器ip:换成你的服务器IP | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
# 用户 | |
REMOTE_USER: 'root' | |
# 目标地址 | |
TARGET: '/www/wwwroot/www.mtsmc.net' |