From 584a92b7cdfcb39dcf7027da1961db026af08cc4 Mon Sep 17 00:00:00 2001 From: LyAhn Date: Mon, 15 Jun 2026 00:36:25 +0100 Subject: [PATCH] ci: report GitHub Actions status to Gitea --- .gitea/workflows/README.md | 20 +++++++++++++ .github/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 .gitea/workflows/README.md diff --git a/.gitea/workflows/README.md b/.gitea/workflows/README.md new file mode 100644 index 0000000..abd74a6 --- /dev/null +++ b/.gitea/workflows/README.md @@ -0,0 +1,20 @@ +# External CI + +CI and release builds run on the GitHub mirror because they require Windows +runner capacity. The GitHub workflows report their state back to this Gitea +repository through the commit status API. + +Keep this directory in the repository. Gitea checks `.gitea/workflows` before +falling back to `.github/workflows`; an existing directory with no workflow +files prevents the GitHub-only workflows from being queued by Gitea Actions. + +## Setup + +1. In Gitea, create an access token with `write:repository` permission for an + account that can update `JezzWTF/phokus`. +2. In the GitHub repository, add that token as the Actions repository secret + `GITEA_STATUS_TOKEN`. + +The status steps are non-blocking. If Gitea is temporarily unavailable, the +GitHub build result is preserved and the failed status update remains visible +in the workflow log. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 803af0f..18c893a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,33 @@ jobs: # windows-latest to match the release target — the ML crates (ort, candle) # and the NSIS bundle only ever ship from Windows. runs-on: windows-latest + env: + GITEA_STATUS_TOKEN: ${{ secrets.GITEA_STATUS_TOKEN }} steps: + - name: Report pending status to Gitea + if: github.event_name != 'pull_request' && env.GITEA_STATUS_TOKEN != '' + continue-on-error: true + shell: pwsh + env: + GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + $headers = @{ + Authorization = "token $env:GITEA_STATUS_TOKEN" + Accept = "application/json" + } + $body = @{ + state = "pending" + context = "github/actions/ci" + description = "GitHub Actions CI is running" + target_url = $env:GITHUB_RUN_URL + } | ConvertTo-Json + Invoke-RestMethod ` + -Method Post ` + -Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" ` + -Headers $headers ` + -ContentType "application/json" ` + -Body $body + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 @@ -52,3 +78,33 @@ jobs: - name: Clippy working-directory: src-tauri run: cargo clippy --all-targets --locked --no-default-features -- -D warnings + + - name: Report final status to Gitea + if: always() && github.event_name != 'pull_request' && env.GITEA_STATUS_TOKEN != '' + continue-on-error: true + shell: pwsh + env: + GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + JOB_STATUS: ${{ job.status }} + run: | + $state = switch ($env:JOB_STATUS) { + "success" { "success" } + "failure" { "failure" } + default { "error" } + } + $headers = @{ + Authorization = "token $env:GITEA_STATUS_TOKEN" + Accept = "application/json" + } + $body = @{ + state = $state + context = "github/actions/ci" + description = "GitHub Actions CI finished: $env:JOB_STATUS" + target_url = $env:GITHUB_RUN_URL + } | ConvertTo-Json + Invoke-RestMethod ` + -Method Post ` + -Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" ` + -Headers $headers ` + -ContentType "application/json" ` + -Body $body diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85265c6..9fde6ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,33 @@ jobs: permissions: contents: write runs-on: windows-latest + env: + GITEA_STATUS_TOKEN: ${{ secrets.GITEA_STATUS_TOKEN }} steps: + - name: Report pending status to Gitea + if: env.GITEA_STATUS_TOKEN != '' + continue-on-error: true + shell: pwsh + env: + GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + $headers = @{ + Authorization = "token $env:GITEA_STATUS_TOKEN" + Accept = "application/json" + } + $body = @{ + state = "pending" + context = "github/actions/release" + description = "GitHub Actions release is running" + target_url = $env:GITHUB_RUN_URL + } | ConvertTo-Json + Invoke-RestMethod ` + -Method Post ` + -Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" ` + -Headers $headers ` + -ContentType "application/json" ` + -Body $body + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 @@ -55,3 +81,33 @@ jobs: # Cargo args after `--`: ship the CPU/DirectML build — default # features enable candle-cuda, which runners (and most users) lack. args: '-- --no-default-features' + + - name: Report final status to Gitea + if: always() && env.GITEA_STATUS_TOKEN != '' + continue-on-error: true + shell: pwsh + env: + GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + JOB_STATUS: ${{ job.status }} + run: | + $state = switch ($env:JOB_STATUS) { + "success" { "success" } + "failure" { "failure" } + default { "error" } + } + $headers = @{ + Authorization = "token $env:GITEA_STATUS_TOKEN" + Accept = "application/json" + } + $body = @{ + state = $state + context = "github/actions/release" + description = "GitHub Actions release finished: $env:JOB_STATUS" + target_url = $env:GITHUB_RUN_URL + } | ConvertTo-Json + Invoke-RestMethod ` + -Method Post ` + -Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" ` + -Headers $headers ` + -ContentType "application/json" ` + -Body $body