Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Update Check

Update Check #17151

Workflow file for this run

name: Update Check
on:
workflow_dispatch:
schedule:
# - cron: "*/30 * * * *" # Every 30 minutes
# - cron: "0 */2 * * *" # Every 2 hours
- cron: "0 */8 * * *" # Every 8 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 "actions@github.com"
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if file exists
run: |
if [[ ! -f latest-parsed-version.md ]]; then
echo "Checking for file latest-parsed-version.md in the repository. This file is necessary for keeping track of the previously built version and comparing it the remote version."
exit 0
fi
- name: Get latest release from inotia00/revanced-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/workflow-dispatch@v1.1
with:
workflow: "Build & Release"
token: ${{ secrets.GITHUB_TOKEN }}