定时拉取最新文件存至本仓 #360
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: 定时拉取最新文件存至本仓 | |
on: | |
workflow_dispatch: # 添加手动运行按钮 | |
schedule: | |
# 每日 13:14 UTC+8 运行一次 | |
- cron: '14 5 * * *' | |
# 每月1日 13:24 UTC+8 运行一次 | |
- cron: '24 5 1 * *' | |
jobs: | |
# 自动拉取最新channel_v3.json | |
FETCH-channel_v3_json: | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: false # To cancel any previously pending (or currently running) job or workflow in the same concurrency group | |
if: github.event.schedule == '14 5 * * *' # 北京时间 每天13:14 | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the added or changed files to the repository. | |
contents: write | |
timeout-minutes: 5 | |
steps: | |
- name: 1.拉取仓库内容 | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
- name: 2.拉取最新channel_v3.json文件到当前目录 | |
run: curl -o ./channel_v3.json https://packagecontrol.io/channel_v3.json | |
- name: 3.判断是否有变更 | |
id: determine_changes | |
uses: UnicornGlobal/has-changes-action@v1.0.11 | |
- name: 4.提交变更 | |
if: steps.determine_changes.outputs.changed == 1 | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -a -m "Github-Actions: file [channel_v3.json] updated at $(date +'%Y-%m-%d %H:%M:%S')" | |
- name: 5.推送到远程仓库 | |
if: steps.determine_changes.outputs.changed != 0 | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
- name: 6.发送一个 Email 提醒 | |
if: steps.determine_changes.outputs.changed != 0 | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
secure: true | |
username: soyadokio@gmail.com | |
password: ${{secrets.GMAIL_APP_PWD}} | |
subject: Github Actions job result | |
to: zdqdj@qq.com | |
from: SoyaDokio | |
body: ${{github.repository}} - channel_v3.json文件有更新,已拉取到仓库sdokio/channel_v3_daily | |
# 自动拉取最新Package Control.sublime-package | |
FETCH-Package-Control_sublime-package: | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: false | |
if: github.event.schedule == '24 5 * * *' # 北京时间 每天13:24 | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the added or changed files to the repository. | |
contents: write | |
timeout-minutes: 5 | |
steps: | |
- name: 1.拉取仓库内容 | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
- name: 2.拉取最新Control.sublime-package文件到当前目录 | |
run: curl -o "./Package Control.sublime-package" https://packagecontrol.io/Package%20Control.sublime-package | |
- name: 3.判断是否有变更 | |
id: determine_changes | |
uses: UnicornGlobal/has-changes-action@v1.0.11 | |
- name: 4.提交变更 | |
if: steps.determine_changes.outputs.changed == 1 | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -a -m "Github-Actions: file [Package Control.sublime-package] updated at $(date +'%Y-%m-%d %H:%M:%S')" | |
- name: 5.推送到远程仓库 | |
if: steps.determine_changes.outputs.changed == 1 | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
- name: 6.发送一个 Email 提醒 | |
if: steps.determine_changes.outputs.changed != 0 | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
secure: true | |
username: soyadokio@gmail.com | |
password: ${{secrets.GMAIL_APP_PWD}} | |
subject: Github Actions job result | |
to: zdqdj@qq.com | |
from: SoyaDokio | |
body: ${{github.repository}} - Control.sublime-package文件有更新,已拉取到仓库sdokio/channel_v3_daily |