Skip to content

Commit 3ad38a6

Browse files
authored
Merge pull request #109 from viktoriia-boiko/pull-request-target-checkout-security-fix
ci: fix fork-PR checkout blocked by security guard
2 parents a0c1c71 + ff466c6 commit 3ad38a6

3 files changed

Lines changed: 70 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/pr-review.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PR Review
2+
3+
on:
4+
workflow_run:
5+
workflows: [Test]
6+
types: [completed]
7+
8+
permissions:
9+
pull-requests: write
10+
actions: read
11+
contents: read
12+
13+
jobs:
14+
review:
15+
runs-on: ubuntu-latest
16+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
17+
18+
steps:
19+
- name: Download PR number
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: pr-number
23+
run-id: ${{ github.event.workflow_run.id }}
24+
github-token: ${{ github.token }}
25+
26+
- name: Read PR number
27+
id: pr
28+
run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT"
29+
30+
- uses: mate-academy/auto-approve-action@v2
31+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
32+
with:
33+
github-token: ${{ github.token }}
34+
pull-request-number: ${{ steps.pr.outputs.number }}
35+
36+
- uses: mate-academy/auto-reject-action@v2
37+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
38+
with:
39+
github-token: ${{ github.token }}
40+
pull-request-number: ${{ steps.pr.outputs.number }}

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up JDK 17
13+
uses: actions/setup-java@v4
14+
with:
15+
java-version: '17'
16+
distribution: 'temurin'
17+
cache: gradle
18+
- name: Build with Gradle
19+
run: ./gradlew build
20+
21+
- name: Save PR number
22+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
23+
run: echo "${{ github.event.pull_request.number }}" > pr-number.txt
24+
25+
- name: Upload PR number
26+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: pr-number
30+
path: pr-number.txt

0 commit comments

Comments
 (0)