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

Remove actions that require write access on pull request #389

Merged
merged 5 commits into from
Oct 22, 2023
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
42 changes: 15 additions & 27 deletions .github/workflows/validate-gentx.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
name: Validate Gentx
on:
# Using pull_request_target to allow forks to write comments and update the
# csv file that is tracking the authors.
# This is OK because of the branch protections we have on the repo so forks
# can't change anything without their PR being approved.
#
# NOTE: This means we should be careful when extending this specific workflow
# file.
pull_request_target:
pull_request:

jobs:
find-gentx-files:
runs-on: ubuntu-latest
outputs:
gentx-files: ${{ steps.set-outputs.outputs.gentx-files }}
gentx-changed: ${{ steps.set-outputs.outputs.gentx-changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed gentx files
id: changed-files
uses: tj-actions/changed-files@v39
Expand All @@ -26,37 +20,31 @@ jobs:
id: set-outputs
run: |
echo "gentx-files=${{ steps.changed-files.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT"
echo "gentx-changed=${{ steps.changed-files.outputs.any_changed }}" >> "$GITHUB_OUTPUT"

jq-format:
needs: find-gentx-files
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ needs.find-gentx-files.outputs.gentx-files != '' }}
steps:
- uses: actions/checkout@v4
- name: List all changed files
- name: Check gentx files against jq
run: |
for file in ${{ needs.find-gentx-files.outputs.gentx-files }}; do
jq . $file >$file"_tmp"
cmp -s $file"_tmp" $file || (echo "$file gentx file not formatted" && exit 1)
formatted=$(jq . $file)
if [ "$formatted" != "$(cat $file)" ]; then
echo "$file gentx file not formatted"
echo "expected:"
echo $formatted
echo "found:"
cat $file
exit 1
fi
done
- name: Add comment about formatting failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please format your gentx by running `jq . path/to/gentx.json > path/to/gentx.json_tmp && mv path/to/gentx.json_tmp path/to/gentx.json` and resubmit the PR.'
})

valid-gentx:
needs: find-gentx-files
runs-on: ubuntu-latest
if: ${{ needs.find-gentx-files.outputs.gentx-files != '' }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
Expand Down