-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (60 loc) · 1.93 KB
/
php-ast-check-diff.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: php-ast check diff
on:
issue_comment:
types: [created]
jobs:
php_ast_check_diff:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: contains(github.event.comment.body, '/php-ast-check-diff')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get PR details
id: pr-details
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const issue_number = context.issue.number;
const {data: pr} = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: issue_number,
});
const result = { baseCommit: pr.base.sha, headCommit: pr.head.sha };
return JSON.stringify(result);
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
- name: Composer Install
run: composer install
- name: Run AST diff check
id: diff
run: |
PR_DETAILS=$(echo '${{ steps.pr-details.outputs.result }}' | jq -r .)
BASE_COMMIT=$(echo $PR_DETAILS | jq -r .baseCommit)
HEAD_COMMIT=$(echo $PR_DETAILS | jq -r .headCommit)
{
echo 'DIFF_CHECK_RESULT<<EOF'
bin/ast-check-diff check --base $BASE_COMMIT --head $HEAD_COMMIT
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Comment PR
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${{ steps.diff.outputs.DIFF_CHECK_RESULT }}`
})