Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Apply security suggestions for gha #1681

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/pr-github-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,47 @@ jobs:
- name: Check for area label
if: always()
run: |
gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | \
gh api --jq '.labels.[].name' /repos/${REPO}/pulls/${NUMBER} | \
grep -q '^area\/' || (echo "area label missing"; exit 1)
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}

- name: Check for kind label
if: always()
run: |
gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | \
gh api --jq '.labels.[].name' /repos/${REPO}/pulls/${NUMBER} | \
grep -q '^kind\/' || (echo "kind label missing"; exit 1)
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}

- name: Check if kind label matches pr title prefix
if: always()
run: |
kind_label=$( gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | grep '^kind/')
kind_label=$( gh api --jq '.labels.[].name' /repos/${REPO}/pulls/${NUMBER} | grep '^kind/')
kind_label_to_pr_title_prefix='{"kind/bug":"fix","kind/feature":"feat","kind/docs":"docs","kind/chore":"chore","kind/flaky-test":"test","kind/missing-test":"test","kind/failing-test":"test","kind/deps":"deps"}'
prefix=$(echo $kind_label_to_pr_title_prefix | jq -r ".\"$kind_label\"")
echo "${{ github.event.pull_request.title }}" | grep '^'$prefix || (echo "PR title should start with $prefix"; exit 1)
echo "$TITLE" | grep '^'$prefix || (echo "PR title should start with $prefix"; exit 1)
env:
GH_TOKEN: ${{ github.token }}
TITLE: ${{ github.event.pull_request.title }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}

- name: Check that there is no do-not-merge label
if: always()
run: |
labels=$(gh api --jq '.labels.[]' /repos/${{ github.repository }}/pulls/${{ github.event.number }} )
labels=$(gh api --jq '.labels.[]' /repos/${REPO}/pulls/${NUMBER} )
echo "Labels found: $( echo $labels | jq -r '.name' )"

! echo "$labels" | jq 'select(.name | startswith("do-not-merge"))' | jq -n "input.name"
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}

pr-title-check:
runs-on: ubuntu-latest
Expand Down
Loading