Update_Checker #3528
This file contains hidden or 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
| # | |
| # Copyright (c) 2019-2026 smallprogram | |
| # | |
| # This is free software, licensed under the MIT License. | |
| # See /LICENSE for more information. | |
| # | |
| # https://github.com/smallprogram/OpenWrtAction | |
| # File: .github/workflows/Update_Checker.yml | |
| # Description: Source code update checker | |
| # | |
| name: Update_Checker | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ssh: | |
| description: 'SSH connection to Actions' | |
| required: false | |
| default: 'false' | |
| schedule: | |
| - cron: '0 16 */3 * *' | |
| # 每三天的UTC 16:00触发 北京时间为每三天的凌晨0点 | |
| permissions: | |
| contents: write | |
| packages: write | |
| actions: write | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: SSH connection to Actions | |
| uses: P3TERX/ssh2actions@v1.0.0 | |
| if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh') | |
| - name: Checkout | |
| uses: actions/checkout@v6 # 建议升级到 v6 | |
| - name: Get Commit Hash | |
| id: getHash | |
| run: | | |
| chmod +x compile_script/update_checker.sh | |
| $GITHUB_WORKSPACE/compile_script/update_checker.sh | |
| - name: Compare Commit Hash | |
| id: cacheHash | |
| uses: actions/cache@v5 | |
| with: | |
| path: .commitHash_All | |
| key: HEAD-${{ steps.getHash.outputs.FINAL_HASH }} # cache的key值,会在job结束后缓存 | |
| - name: Save New Commit Hash | |
| if: steps.cacheHash.outputs.cache-hit != 'true' | |
| run: | | |
| echo ${{ steps.getHash.outputs.HASH_STRING }} | tee .commitHash_All | |
| - name: Delete workflow runs | |
| uses: Mattraks/delete-workflow-runs@main | |
| with: | |
| token: ${{ github.token }} | |
| repository: ${{ github.repository }} | |
| retain_days: 90 | |
| - name: Remove old Releases | |
| uses: dev-drprasad/delete-older-releases@master | |
| with: | |
| keep_latest: 10 | |
| keep_min_download_counts: 2 | |
| delete_expired_data: 30 | |
| delete_tags: true | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: ghcr.io cleanup action | |
| uses: dataaxiom/ghcr-cleanup-action@v1 | |
| continue-on-error: true | |
| with: | |
| delete-untagged: true | |
| packages: openwrt-base-cache* | |
| expand-packages: true | |
| token: ${{ secrets.MY_SECRET_PAT }} | |
| - name: Stateful Lifecycle Check | |
| id: lifecycle_check | |
| run: | | |
| chmod +x compile_script/check_lifecycle.sh | |
| $GITHUB_WORKSPACE/compile_script/check_lifecycle.sh | |
| - name: Trigger build | |
| if: steps.cacheHash.outputs.cache-hit != 'true' | |
| uses: peter-evans/repository-dispatch@main | |
| with: | |
| token: ${{ github.token }} | |
| event-type: openwrt_source_update_v6 | |
| client-payload: '{"force_rebuild": "${{ steps.lifecycle_check.outputs.force_rebuild }}"}' |