Skip to content

Commit 3e1e9d7

Browse files
authored
fix: exclude self lgtm.toml from ending up in docker file (#78)
1 parent 0b2ed6f commit 3e1e9d7

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ tests/
4040
# Poetry files you don't need in container (optional)
4141
poetry.lock # If you're using only pyproject.toml
4242

43+
# Configuration files (users provide their own)
44+
lgtm.toml
45+
4346
# Docker files
4447
Dockerfile
4548
.dockerignore

.github/workflows/lgtm.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ on:
55
types: [created]
66

77
jobs:
8-
lgtm-review:
8+
check-permission:
99
if: |
1010
github.event.issue.pull_request &&
1111
startsWith(github.event.comment.body, '/lgtm review')
1212
runs-on: ubuntu-latest
13+
outputs:
14+
has-permission: ${{ steps.check.outputs.has-permission }}
1315
steps:
1416
- name: Check if commenter has write access
15-
id: check-permission
17+
id: check
1618
env:
1719
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1820
run: |
@@ -22,28 +24,27 @@ jobs:
2224
https://api.github.com/repos/$REPO/collaborators/$USER/permission \
2325
| jq -r '.permission')
2426
25-
2627
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "maintain" || "$PERMISSION" == "write" ]]; then
27-
echo "HAS_PERMISSION=true" >> $GITHUB_ENV
28+
echo "has-permission=true" >> $GITHUB_OUTPUT
2829
else
29-
echo "HAS_PERMISSION=false" >> $GITHUB_ENV
30+
echo "has-permission=false" >> $GITHUB_OUTPUT
3031
fi
3132
32-
- name: Fail if unauthorized
33-
if: env.HAS_PERMISSION == 'false'
34-
run: |
35-
echo "User ${{ github.event.comment.user.login }} is not authorized to trigger this workflow."
36-
exit 1
37-
33+
lgtm-review:
34+
needs: check-permission
35+
if: needs.check-permission.outputs.has-permission == 'true'
36+
runs-on: ubuntu-latest
37+
container:
38+
image: elementsinteractive/lgtm-ai
39+
steps:
3840
- name: Checkout PR code
3941
uses: actions/checkout@v4
4042
with:
4143
ref: refs/pull/${{ github.event.issue.number }}/merge
4244

4345
- name: Run LGTM Review
4446
run: |
45-
docker run --rm elementsinteractive/lgtm-ai \
46-
review \
47+
lgtm review \
4748
--pr-url "https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}" \
4849
--git-api-key "${{ secrets.GITHUB_TOKEN }}" \
4950
--ai-api-key "${{ secrets.AI_API_TOKEN }}" \

0 commit comments

Comments
 (0)