Gate the GitHub release workflow on a repo variable, not server_url
The github.server_url guard did not keep this workflow from running on Gitea: Gitea reports github.server_url as https://github.com, so the condition was true there too and the jobs ran (and would fail on @v4/gh). Switch both job guards to `vars.GITHUB_RELEASE == 'true'`, a repository variable set only in the GitHub repo's settings. It is deterministic: absent on Gitea, so the jobs skip there and the .gitea workflow is the one that runs; present on GitHub once configured, so it runs there. The header documents how to set it (Settings → Secrets and variables → Actions → Variables → GITHUB_RELEASE=true). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
99f4cf0220
commit
a2a628aa3d
1 file changed
+10
-5
@@ -6,9 +6,14 @@ name: Release
|
|||||||
# artifact backend and fills the release with `gh`.
|
# artifact backend and fills the release with `gh`.
|
||||||
#
|
#
|
||||||
# Gitea reads both .gitea/workflows and .github/workflows, so without a guard it
|
# Gitea reads both .gitea/workflows and .github/workflows, so without a guard it
|
||||||
# would also try to run this file and fail on @v4 and `gh`. Every job is gated
|
# would also try to run this file and fail on @v4 and `gh`. (Gitea reports
|
||||||
# on running on github.com, so on Gitea they are simply skipped — the Gitea file
|
# github.server_url as https://github.com, so that cannot tell the two apart.)
|
||||||
# is the one that runs there.
|
# Instead every job is gated on a repository variable GITHUB_RELEASE=true, which
|
||||||
|
# is set only in the GitHub repository's settings — so on Gitea, where it is
|
||||||
|
# absent, these jobs are skipped and the .gitea file is the one that runs.
|
||||||
|
#
|
||||||
|
# To enable on GitHub: Settings → Secrets and variables → Actions → Variables →
|
||||||
|
# New variable, name GITHUB_RELEASE, value true.
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ["v*"]
|
tags: ["v*"]
|
||||||
@@ -23,7 +28,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: ${{ matrix.asset }}
|
name: ${{ matrix.asset }}
|
||||||
if: ${{ github.server_url == 'https://github.com' }}
|
if: ${{ vars.GITHUB_RELEASE == 'true' }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -144,7 +149,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
name: Publish release
|
name: Publish release
|
||||||
needs: build
|
needs: build
|
||||||
if: ${{ github.server_url == 'https://github.com' }}
|
if: ${{ vars.GITHUB_RELEASE == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|||||||
Reference in new issue
Block a user