Sy-Update-ck-Run-wiki #1612
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: Sy-Update-ck-Run-wiki | |
on: | |
schedule: | |
- cron: '0 */2 * * *' | |
workflow_dispatch: | |
jobs: | |
sync-and-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Add upstream repository | |
run: git remote add upstream https://github.com/ColdeZhang/Dominion.git | |
- name: Fetch all upstream branches | |
run: git fetch upstream | |
- name: Checkout upstream changes excluding .github | |
run: | | |
git checkout upstream/master -- . | |
git reset -- .github | |
- name: Clean untracked files, preserving .github directory | |
run: | | |
git clean -fdx -e .github | |
- name: Set up Git user | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "yunshuangqwq" | |
- name: Clear and update main README.md first line | |
run: | | |
TZ=Asia/Shanghai | |
export TZ | |
DATE=$(date "+%Y年%m月%d日 %H时%M分") | |
sed -i '1d' README.md | |
echo -e "<div align="center">" | cat - README.md > temp && mv temp README.md | |
echo -e "fork于($DATE),本仓库非Dominion插件仓库,由于源Dominion文档网站访问有点慢就fork下来套了个反向代理(已征得作者同意),若要获取最新Dominion插件信息请前往上游仓库!" | cat - README.md > temp && mv temp README.md | |
echo -e "## 镜像的文档:[点击跳转](https://dom.yunr.us.kg)" | cat - README.md > temp && mv temp README.md | |
echo -e "## 上游仓库:[点击跳转](https://github.com/ColdeZhang/Dominion)" | cat - README.md > temp && mv temp README.md | |
- name: Clear and update docs/zh-cn/README.md first line | |
run: | | |
TZ=Asia/Shanghai | |
export TZ | |
DATE=$(date "+%Y年%m月%d日 %H时%M分") | |
sed -i '1d' docs/zh-cn/README.md | |
echo -e "# 镜像 Dominion 文档 - 于($DATE)fork - 源文档:[点击跳转](https://dominion.lunadeer.cn)" | cat - docs/zh-cn/README.md > temp && mv temp docs/zh-cn/README.md | |
- name: Commit and push changes | |
run: | | |
git add README.md docs/zh-cn/README.md | |
git commit -m "Update README.md files with the latest date and link" || echo "No changes to commit" | |
git push origin master --force | |
- name: Trigger wiki.yml workflow | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Content-Type: application/json" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/wiki.yml/dispatches \ | |
-d '{"ref": "master"}' |