Skip to content

Commit ba4c988

Browse files
committed
Fix GitHub Actions permissions for lua-format workflow
1 parent f0f2e9c commit ba4c988

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/workflows/lua-format.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
lua-formatter:
1313
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
1417
steps:
1518
- name: Set up Git
1619
if: ${{ github.ref != 'refs/heads/main' }}
@@ -21,9 +24,10 @@ jobs:
2124
if: ${{ github.ref != 'refs/heads/main' }}
2225
uses: actions/checkout@v3
2326
with:
24-
repository: ${{ github.event.pull_request.head.repo.full_name }}
25-
ref: ${{ github.event.pull_request.head.ref }}
27+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
28+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
2629
token: ${{ secrets.GITHUB_TOKEN }}
30+
fetch-depth: 0
2731

2832
- uses: JohnnyMorganz/stylua-action@v3
2933
with:
@@ -32,7 +36,7 @@ jobs:
3236
args: .
3337

3438
- name: Run add and commit
35-
if: ${{ github.ref != 'refs/heads/main' }}
39+
if: ${{ github.ref != 'refs/heads/main' && github.event_name == 'pull_request' }}
3640
uses: EndBug/add-and-commit@v9
3741
with:
3842
author_name: GitHub Actions

0 commit comments

Comments
 (0)