改用脚本来检查了,一脚踢开 github-scripts。

This commit is contained in:
LamGC 2023-03-18 23:26:51 +08:00
parent 12deafa8ec
commit 826c7d738d
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 14 additions and 17 deletions

View File

@ -9,26 +9,19 @@ permissions:
contents: write contents: write
jobs: jobs:
# 检查 jenkinsci/docker-inbound-agent 仓库的最新版本,并将最新版本写入到 LATEST_VERSION 文件中 # 检查 jenkinsci/docker-inbound-agent 仓库的最新版本,并使用 actions/github-script 向 LATEST_VERSION 文件写入最新版本号。
check-updates: check-updates:
timeout-minutes: 5 timeout-minutes: 30
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Check updates - name: Check updates
uses: actions/github-script@v5 run: chmod +x ./update-version.sh && ./update-version.sh
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with: with:
script: | commit_message: Update LATEST_VERSION
const { data: { tag_name: latestVersion } } = await github.repos.getLatestRelease({ commit_options: '--no-verify'
owner: 'jenkinsci', file_pattern: LATEST_VERSION
repo: 'docker-inbound-agent',
});
await github.repos.createOrUpdateFileContents({
owner: context.repo.owner,
repo: context.repo.repo,
path: 'LATEST_VERSION',
message: `Update LATEST_VERSION to ${latestVersion}`,
content: Buffer.from(latestVersion).toString(),
sha: context.sha,
});

4
update-version.sh Normal file
View File

@ -0,0 +1,4 @@
LATEST_VERSION=$(curl -s https://api.github.com/repos/jenkinsci/docker-inbound-agent/releases/latest | grep tag_name | cut -d '"' -f 4)
if [ "$LATEST_VERSION" != "$(cat LATEST_VERSION)" ]; then
echo "$LATEST_VERSION" > LATEST_VERSION
fi