.github: narrow token scopes and fix silent CI failures

Jobs inherited write scopes they never use, so each workflow now
defaults to contents: read and grants pull-requests: read or
packages: write only to the jobs whose GITHUB_TOKEN calls need them.
The autobump bump job keeps its own block.

Failures that read as success now fail the step: a failed gh call in
nvchecker-check.py no longer reads as "no issue" and opens a duplicate,
and fleet-keeper no longer reports "found 0" when listing repositories
or workflows fails.

emerge-targets.sh took =cat/foo-bar-1.0 for a version of cat/foo, so a
PR touching both dropped cat/foo; only a digit after the dash starts a
version.

setup-gentoo added the x86-64 binhost on arm64 as well; it is now
added on amd64 only.

mirror-to-codeberg trusted whatever ssh-keyscan returned while holding
a write key; the host key is now pinned and checked.

stage3 cleanup ran even when build was skipped on a fork schedule.

Signed-off-by: Zakk <zakk@gentoozh.org>
This commit is contained in:
Zakk committed 2026-10-11 04:26:16 +11:00
1 parent b598d725b8
commit 8900587f7b
13 files changed
+49 -14

No files matched your search

+3 -1
View File
@@ -27,11 +27,13 @@ runs:
FETCHCOMMAND="\${FETCHCOMMAND} --no-verbose"
RESUMECOMMAND="\${RESUMECOMMAND} --no-verbose"
EOF
cat > /etc/portage/binrepos.conf/ci.conf << EOF
if [ "$(portageq envvar ARCH)" = amd64 ]; then
cat > /etc/portage/binrepos.conf/ci.conf << EOF
[$(cat profiles/repo_name)-binhost]
sync-uri = https://distfiles.gentoozh.org/binpkgs/x86-64
priority = 2
EOF
fi
mkdir -p /etc/portage/package.use
printf '%s\n' 'dev-qt/qtwebengine bindist' 'net-libs/webkit-gtk keyring' > /etc/portage/package.use/ci
cat /etc/portage/make.conf
+1 -3
View File
@@ -39,9 +39,7 @@ concurrency:
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
issues: write
contents: read
jobs:
env:
+6 -1
View File
@@ -13,16 +13,21 @@ concurrency:
permissions:
contents: read
packages: write
jobs:
stage3:
if: github.repository == 'gentoo-zh/overlay' || github.event_name == 'workflow_dispatch'
permissions:
contents: read
packages: write
uses: ./.github/workflows/stage3.yml
autobump-env:
needs: stage3
if: ${{ !cancelled() && needs.stage3.result != 'skipped' }}
permissions:
contents: read
packages: write
uses: ./.github/workflows/autobump-env.yml
with:
force: true
+6
View File
@@ -13,10 +13,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
scan:
name: scan changed ebuilds
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
targets: ${{ steps.packages.outputs.targets }}
image: ${{ steps.image.outputs.ref }}
+5 -3
View File
@@ -25,9 +25,11 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
seen=0; enabled=0
for repo in $(gh repo list gentoo-zh-drafts --limit 300 --json name -q '.[].name'); do
for id in $(gh api "repos/gentoo-zh-drafts/$repo/actions/workflows" \
--jq '.workflows[] | select(.state == "disabled_inactivity") | .id' 2>/dev/null); do
repos=$(gh repo list gentoo-zh-drafts --limit 300 --json name -q '.[].name')
for repo in $repos; do
ids=$(gh api "repos/gentoo-zh-drafts/$repo/actions/workflows" \
--jq '.workflows[] | select(.state == "disabled_inactivity") | .id')
for id in $ids; do
seen=$((seen + 1))
if gh api -X PUT "repos/gentoo-zh-drafts/$repo/actions/workflows/$id/enable" >/dev/null 2>&1; then
enabled=$((enabled + 1)); echo "re-enabled $repo"
@@ -10,6 +10,9 @@ concurrency:
group: deps-table
cancel-in-progress: false
permissions:
contents: read
jobs:
generate:
if: github.repository == 'gentoo-zh/overlay' || github.event_name == 'workflow_dispatch'
+7 -3
View File
@@ -10,6 +10,9 @@ on:
concurrency:
group: mirror-to-codeberg
permissions:
contents: read
jobs:
mirror:
runs-on: ubuntu-latest
@@ -23,10 +26,11 @@ jobs:
env:
SSH_KEY: ${{ secrets.CODEBERG_SSH_KEY }}
run: |
mkdir -p ~/.ssh
install -dm700 ~/.ssh
printf '%s\n' "$SSH_KEY" > ~/.ssh/codeberg_mirror
chmod 600 ~/.ssh/codeberg_mirror
ssh-keyscan codeberg.org >> ~/.ssh/known_hosts 2>/dev/null
export GIT_SSH_COMMAND="ssh -i ~/.ssh/codeberg_mirror"
# matches the fingerprint at https://docs.codeberg.org/security/ssh-fingerprint/
echo 'codeberg.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIVIC02vnjFyL+I4RHfvIGNtOgJMe769VTF1VR4EB3ZB' > ~/.ssh/known_hosts
export GIT_SSH_COMMAND="ssh -i ~/.ssh/codeberg_mirror -o StrictHostKeyChecking=yes"
git push --prune git@codeberg.org:gentoo-zh/overlay.git \
'+refs/heads/*:refs/heads/*' '+refs/tags/*:refs/tags/*'
+3
View File
@@ -8,6 +8,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
eix:
if: github.repository == 'gentoo-zh/overlay'
+6
View File
@@ -8,6 +8,9 @@ on:
branches:
- master
permissions:
contents: read
jobs:
scan:
runs-on: ubuntu-latest
@@ -23,6 +26,9 @@ jobs:
commits:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v7
+1 -1
View File
@@ -60,7 +60,7 @@ jobs:
cleanup:
needs: build
if: always()
if: ${{ !cancelled() && needs.build.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- name: drop replaced images
+6
View File
@@ -15,11 +15,17 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}${{ github.event.action == 'labeled' && github.event.label.name != 'tatt' && '-label' || '' }}
cancel-in-progress: true
permissions:
contents: read
jobs:
scan:
name: scan changed ebuilds
if: github.event.action != 'labeled' || github.event.label.name == 'tatt'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
targets: ${{ steps.targets.outputs.targets }}
image: ${{ steps.image.outputs.ref }}
+1 -1
View File
@@ -43,7 +43,7 @@ atoms=$(
if [[ "$atom" != =* ]]; then
versioned=false
for candidate in "${packages[@]}"; do
if [[ "$candidate" == "=$atom-"* ]]; then
if [[ "$candidate" == "=$atom-"[0-9]* ]]; then
versioned=true
break
fi
+1 -1
View File
@@ -17,7 +17,7 @@ repo = os.environ["GITHUB_REPOSITORY"]
def gh(*args):
return subprocess.run(["gh", *args, "--repo", repo], stdout=subprocess.PIPE, text=True).stdout
return subprocess.run(["gh", *args, "--repo", repo], stdout=subprocess.PIPE, text=True, check=True).stdout
def report(pkg, ver, maintainers):