Skip to content

CI

CI #530

Workflow file for this run

name: CI
on:
workflow_dispatch:
schedule:
- cron: "0 16 * * *"
jobs:
check:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Should build?
id: should_build
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source utils.sh
toml_prep "$(cat config.toml)"
is_youtube_latest() {
t=$(toml_get_table YouTube)
v=$(toml_get "$t" "version") || v=""
if isoneof "$v" latest beta; then
cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
[ -z "$cur_yt" ] && return 1 # empty, fail=>dont build
if [ "$v" = beta ]; then aav="true"; else aav="false"; fi
last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver)
[ -z "$last_ver" ] && return 1 # cant fetch, dont build
echo "current yt version: '$cur_yt'"
echo "latest yt version: '$last_ver'"
[ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build
else
return 1 # not experimental, dont build
fi
}
is_patches_latest() {
PATCHES_SRC=$(toml_get "$(toml_get_table "")" patches-source) || PATCHES_SRC="ReVanced/revanced-patches"
last_patches_url=$(gh_req https://api.github.com/repos/${PATCHES_SRC}/releases/latest - | json_get 'browser_download_url' | grep 'jar')
last_patches=${last_patches_url##*/}
cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs)
echo "current patches version: $cur_patches"
echo "latest patches version: $last_patches"
if [ -z "$cur_patches" ] || [ -z "$last_patches" ]; then return 1; fi
[ "$cur_patches" != "$last_patches" ] # 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
- name: Clear older runs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run list -L400 --json databaseId -q '.[].databaseId' | tail -n+10 | xargs -IID gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/actions/runs/ID" -X DELETE || :
outputs:
SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }}
build:
permissions: write-all
needs: check
uses: ./.github/workflows/build.yml
if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }}
secrets: inherit