Check and Update #1787
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: Check and Update | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "2 */2 * * *" | |
push: | |
branches: | |
- main | |
paths: | |
- ".github/nvchecker.toml" | |
- ".github/renovate.json" | |
- ".github/workflows/run-nvchecker-and-renovate.yml" | |
jobs: | |
check-versions: | |
runs-on: ubuntu-latest | |
container: | |
image: archlinux:base-devel | |
permissions: | |
contents: write | |
steps: | |
- name: 安装依赖 | |
run: pacman -Syyuu --noconfirm --needed --ignore filesystem nvchecker wget jq | |
- name: 导入仓库 | |
uses: actions/checkout@v4 | |
- name: 配置环境 | |
run: sed -i -e "s/__GITHUB_ACCESS_TOKEN__/${{ secrets.GITHUB_TOKEN }}/g" ./.github/keyfile.toml | |
- name: 运行 Nvchecker | |
working-directory: ./.github | |
run: | | |
wget https://github.com/CAB233/myAUR/releases/download/nvchecker/old_ver.json || true | |
# keyfile 用于提升 GitHub API 请求限额 | |
nvchecker --file nvchecker.toml --keyfile keyfile.toml | |
# 精简输出内容 | |
jq '.data |= with_entries(.value |= {version: .version})' new_ver.json > temp.json | |
mv temp.json new_ver.json | |
nvcmp --file nvchecker.toml > result.tmp | |
nvtake --file nvchecker.toml --all | |
- name: 推送更新通知 | |
run: | | |
RESULT=$(cat ./.github/result.tmp | sed 's/$/ /') \ | |
&& [[ ! -z $RESULT ]] \ | |
&& curl "https://${{ secrets.SERVERCHAN_UID }}.push.ft07.com/send/${{ secrets.SERVERCHAN_SENDKEY }}.send" \ | |
--data-urlencode "title=软件包更新" \ | |
--data-urlencode "desp=$RESULT" \ | |
|| echo "没有发现更新" \ | |
- name: 获取当前构建时间 | |
run: echo "builddate=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT | |
id: date | |
- name: 上传至 GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifactErrorsFailBuild: true | |
removeArtifacts: true | |
allowUpdates: true | |
generateReleaseNotes: false | |
tag: nvchecker | |
name: ${{ steps.date.outputs.builddate }} | |
artifacts: "./.github/new_ver.json, ./.github/old_ver.json" | |
prerelease: true | |
body: | | |
Version Record Files | |
update-versions: | |
needs: check-versions | |
runs-on: ubuntu-latest | |
steps: | |
- name: 生成 Token | |
uses: actions/create-github-app-token@v1 | |
id: generate-token | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- name: 导入仓库 | |
uses: actions/checkout@v4 | |
- name: 运行 Renovate | |
uses: renovatebot/[email protected] | |
with: | |
configurationFile: .github/renovate.json | |
token: "${{ steps.generate-token.outputs.token }}" |