This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
CI #881
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: CI | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */4 * * *" | |
jobs: | |
check: | |
name: Check if everything is up to date | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Should build? | |
id: should_build | |
shell: bash | |
run: | | |
source build.conf | |
source utils.sh | |
is_youtube_latest() { | |
if [ "${YOUTUBE_MODE%/*}" = latest ]; then | |
declare -r cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) | |
[ -z "$cur_yt" ] && return 1 # empty, fail=>dont build | |
declare -r last_ver=$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver) | |
echo "current yt version: $cur_yt" | |
echo "latest yt version: $last_ver" | |
[ "$cur_yt" != "$last_ver" ] && [[ "$last_patches" == *"jar"* ]] # test success=>build, fail=>dont build | |
else | |
return 1 # not experimental, dont build | |
fi | |
} | |
is_patches_latest() { | |
declare -r last_patches_extended_json=$(wget -nv -O- --header="$WGET_HEADER" https://api.github.com/repos/inotia00/revanced-patches/releases/latest) | |
declare -r last_patches_url_extended=$(echo ${last_patches_extended_json} | json_get 'browser_download_url' 'jar') | |
declare -r last_patches_ver_extended=$(echo ${last_patches_extended_json} | json_get 'tag_name') | |
declare -r last_patches_json=$(wget -nv -O- --header="$WGET_HEADER" https://api.github.com/repos/revanced/revanced-patches/releases/latest) | |
declare -r last_patches_url=$(echo ${last_patches_json} | json_get 'browser_download_url' 'jar') | |
declare -r last_patches_ver=$(echo ${last_patches_json}| json_get 'tag_name') | |
declare -r last_patches="[${last_patches_url_extended##*/}](https://github.com/inotia00/revanced-patches/releases/tag/${last_patches_ver_extended}) [${last_patches_url##*/}](https://github.com/revanced/revanced-patches/releases/tag/${last_patches_ver})" | |
cur_patches="$(sed -n 's/.*Patches (Extended): \(.*\)/\1/p' build.md | xargs) $(sed -n 's/.*Patches: \(.*\)/\1/p' build.md | xargs)" | |
echo "latest patches version: $last_patches" | |
echo "current patches version: $cur_patches" | |
[ "$cur_patches" != "$last_patches" ] && [[ "$last_patches" == *"jar"* ]] # test success=>build, fail=>dont build | |
} | |
if ! git checkout update; then | |
echo "first time building!" | |
echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT | |
elif is_patches_latest || is_youtube_latest; then | |
echo "build!" | |
echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT | |
else | |
echo "dont build!" | |
echo "SHOULD_BUILD=0" >> $GITHUB_OUTPUT | |
fi | |
outputs: | |
SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }} | |
build: | |
name: Build APKs | |
needs: check | |
uses: ./.github/workflows/build.yml | |
if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }} | |
cleanup: | |
name: Cleanup | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
steps: | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
retain_days: 3 | |
keep_minimum_runs: 3 | |
delete_run_by_conclusion_pattern: success | |
- name: Delete Older Releases | |
uses: dev-drprasad/delete-older-releases@v0.2.1 | |
with: | |
keep_latest: 2 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |