Update Checker #47
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
# | |
# Copyright (c) 2019-2021 P3TERX <https://p3terx.com> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# https://github.com/P3TERX/Actions-OpenWrt | |
# File: .github/workflows/update-checker.yml | |
# Description: Source code update checker | |
# | |
name: Update Checker | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: openwrt-24.10 | |
on: | |
workflow_dispatch: | |
inputs: | |
update: | |
description: 'Forced Updating' | |
required: false | |
default: 'false' | |
type: boolean | |
schedule: | |
- cron: 18 18 * * * | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Commit Hash | |
id: getHash | |
run: | | |
git clone --depth 1 $REPO_URL -b $REPO_BRANCH . | |
echo "commitHash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Compare Commit Hash | |
id: cacheHash | |
uses: actions/cache@main | |
with: | |
path: .commitHash | |
key: HEAD-${{ steps.getHash.outputs.commitHash }} | |
- name: Save New Commit Hash | |
if: steps.cacheHash.outputs.cache-hit != 'true' | |
run: | | |
echo ${{ steps.getHash.outputs.commitHash }} | tee .commitHash | |
- name: Trigger build | |
if: steps.cacheHash.outputs.cache-hit != 'true' || github.event.inputs.update == 'true' | |
uses: peter-evans/repository-dispatch@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
event-type: Source Code Update | |
- name: Remove old Releases and workflow runs | |
uses: ophub/delete-releases-workflows@main | |
with: | |
gh_token: ${{ secrets.GITHUB_TOKEN }} | |
delete_releases: true | |
releases_keep_latest: 3 | |
delete_tags: true | |
delete_workflows: true | |
workflows_keep_day: 3 | |