diff --git a/.gitea/workflows/trigger-mobile.yml b/.gitea/workflows/trigger-mobile.yml new file mode 100644 index 0000000..2aff32f --- /dev/null +++ b/.gitea/workflows/trigger-mobile.yml @@ -0,0 +1,53 @@ +name: Trigger cinny-mobile + +on: + push: + branches: + - main + +jobs: + dispatch: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.head_commit.message || '', '[skip mobile]') }} + steps: + - name: Dispatch update-submodule on cinny-mobile + env: + # Prefer a PAT with Actions write on cinny-mobile (secret name: GITEA_TOKEN). + # Default GITHUB_TOKEN is usually scoped to this repo only. + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + API_BASE: ${{ github.server_url }}/api/v1 + CINNY_SHA: ${{ github.sha }} + run: | + set -euo pipefail + + TOKEN="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}" + if [ -z "${TOKEN}" ]; then + echo "No GITEA_TOKEN/GITHUB_TOKEN available to dispatch cinny-mobile" + exit 1 + fi + + BODY=$(jq -n \ + --arg ref "master" \ + --arg sha "${CINNY_SHA}" \ + '{ref: $ref, inputs: {cinny_sha: $sha}}') + + echo "Dispatching litruv/cinny-mobile update-submodule.yml for ${CINNY_SHA}" + HTTP_CODE=$(curl -sS -o /tmp/dispatch-body.txt -w "%{http_code}" \ + -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d "${BODY}" \ + "${API_BASE}/repos/litruv/cinny-mobile/actions/workflows/update-submodule.yml/dispatches?return_run_details=true") + + echo "HTTP ${HTTP_CODE}" + cat /tmp/dispatch-body.txt || true + echo + + case "${HTTP_CODE}" in + 200|201|204) echo "Dispatch accepted" ;; + *) + echo "Dispatch failed" + exit 1 + ;; + esac