Update Check #16819
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: Update Check | |
on: | |
workflow_dispatch: | |
schedule: | |
# - cron: "*/30 * * * *" # Every 30 minutes | |
# - cron: "0 */2 * * *" # Every 2 hours | |
- cron: "0 */12 * * *" # Every 12 hours | |
jobs: | |
check-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Configure git | |
run: | | |
git config --global user.name "actions-user" | |
git config --global user.email "[email protected]" | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Check if file exists | |
run: | | |
if [[ ! -f latest-parsed-version.md ]]; then | |
echo "The file latest-parsed-version.md was not found at the base of the repository. This file is necessary for keeping track of the previously built version and compare it the remote version. To avoid generating failed runs, the workflow will now be interrupted." | |
exit 0 | |
fi | |
- name: Get latest release from YT-Advanced/ReX-patches | |
id: latest-release | |
run: | | |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/inotia00/revanced-patches/releases/latest | jq -r '.tag_name') | |
if [ "$LATEST_RELEASE" == "null" ]; then | |
echo "Couldn't fetch latest release. Workflow halted!" | |
exit 0 | |
fi | |
echo "::set-output name=tag_name::$LATEST_RELEASE" | |
- name: Compare with local version | |
run: | | |
LOCAL_VERSION=$(cat apks/latest-parsed-version.md) | |
if [ "$LOCAL_VERSION" == "${{ steps.latest-release.outputs.tag_name }}" ]; then | |
echo "Already up-to-date!" | |
else | |
echo "Local reported version doesn't match fetched version, updating local version." | |
echo "${{ steps.latest-release.outputs.tag_name }}" > apks/latest-parsed-version.md | |
git add apks/latest-parsed-version.md | |
git commit -m "Update latest-parsed-version.md" | |
git push | |
echo "::set-output name=trigger_build::true" | |
fi | |
id: compare-version | |
- name: Verify local version update | |
if: ${{ steps.compare-version.outputs.trigger_build == 'true' }} | |
run: | | |
UPDATED_VERSION=$(cat apks/latest-parsed-version.md) | |
if [ "$UPDATED_VERSION" == "${{ steps.latest-release.outputs.tag_name }}" ]; then | |
echo "Local version updated successfully!" | |
else | |
echo "Error updating local version control file, halting workflow!" | |
exit 1 | |
fi | |
- name: Trigger build workflow | |
if: ${{ steps.compare-version.outputs.trigger_build == 'true' }} | |
uses: benc-uk/[email protected] | |
with: | |
workflow: "Build & Release" | |
token: ${{ secrets.GITHUB_TOKEN }} |