Skip to content

Commit 9028d17

Browse files
committed
Check that code owners have write access for the regular review
1 parent 1d10641 commit 9028d17

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

.github/workflows/review.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,26 @@ jobs:
1111
update:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: cachix/install-nix-action@v26
15+
1416
- uses: actions/checkout@v4
17+
with:
18+
path: repo
19+
20+
- name: Generate issue body
21+
run: repo/scripts/review-body.sh repo ${{ github.repository }} > body
22+
env:
23+
# This token has read-only admin access to see who has write access to this repo
24+
GH_TOKEN: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}"
25+
1526
- run: |
1627
gh api \
1728
--method POST \
1829
-H "Accept: application/vnd.github+json" \
1930
-H "X-GitHub-Api-Version: 2022-11-28" \
20-
/repos/"$GITHUB_REPOSITORY"/issues \
31+
/repos/${{ github.repository }}/issues \
2132
-f title="[$(date +'%Y %B')] Regular manual review " \
22-
-f body="$(./scripts/review-body.sh)"
33+
-F body=@body
2334
env:
35+
# This token has write access to only issues to create one
2436
GH_TOKEN: ${{ github.token }}

scripts/review-body.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash --pure --keep GH_TOKEN -I nixpkgs=channel:nixpkgs-unstable -p codeowners github-cli gitMinimal
3+
24
set -euo pipefail
35

46
# This script outputs the contents of the regular review issue, see ./github/workflows/review.yml
57

6-
rev=$(git rev-parse HEAD)
8+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
10+
if (( $# != 2 )); then
11+
echo "Usage: $0 PATH OWNER/REPO"
12+
exit 1
13+
fi
14+
15+
root=$1
16+
repo=$2
17+
18+
rev=$(git -C "$root" rev-parse HEAD)
719

820
echo "Because the documentation in this repository may slowly deviate from reality, this monthly issue is created to regularly review the files.
921
@@ -30,4 +42,11 @@ while read -r file users; do
3042
continue
3143
fi
3244
echo "- [ ] \`$file\`: $users"
33-
done < .github/CODEOWNERS
45+
done < "$root"/.github/CODEOWNERS
46+
47+
echo ""
48+
49+
# Check that all code owners have write permissions
50+
# `|| true` because this script fails when there are code owners without permissions,
51+
# which is useful to fail PRs, but not here
52+
bash "$SCRIPT_DIR"/unprivileged-owners.sh "$root" "$repo" || true

0 commit comments

Comments
 (0)