Skip to content

Change Github Action permissions #34

Change Github Action permissions

Change Github Action permissions #34

name: Check if commit message body is not too short
on:
pull_request_target:
types: [opened, synchronize, edited, reopened]
pull_request:
types: [opened, synchronize, edited, reopened]
permissions: {}
jobs:
verify-body-length:
runs-on: ubuntu-latest
# set as non-voting for now.
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate GitHub App Token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.COMMENTER_APP_ID }}
private-key: ${{ secrets.COMMENTER_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Post comment
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'my comment'
})
- name: Dump commit message to file
run: |
git fetch origin ${{ github.event.pull_request.head.sha }}
git log -1 --pretty=format:"%B" ${{ github.event.pull_request.head.sha }} > commit-message-file
- name: Run commit message check
id: bodylength
run: |
set +e
./scripts/git-check-commit-body-length.sh commit-message-file > result.log 2>&1
EXIT_CODE=$?
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
cat result.log
- name: Comment on PR if body length check failed
if: steps.bodylength.outputs.exit_code != '0'
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: ./result.log
reactions: confused
token: ${{ steps.generate_token.outputs.token }}