-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (71 loc) · 2.35 KB
/
action.yml
File metadata and controls
81 lines (71 loc) · 2.35 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: 'PHP AST Changed'
description: 'Check if PHP AST have been changed in a pull request'
inputs:
php-version:
description: 'PHP version https://github.com/shivammathur/setup-php#tada-php-support'
required: false
default: '8.1'
ast-version:
description: 'AST version https://github.com/nikic/php-ast#ast-versioning'
required: false
default: '85'
outputs:
changed:
description: 'AST of *.php files have changed: "true" (string), not changed: "false" (string)'
value: ${{ steps.diff.outputs.exists }}
runs:
using: 'composite'
steps:
# setup
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: ast
# paths
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Download util.php
run: |
<?php
declare(strict_types=1);
$php_ast_version = phpversion('ast');
$url = "https://raw.githubusercontent.com/nikic/php-ast/v{$php_ast_version}/util.php";
echo $url;
$contents = file_get_contents($url);
file_put_contents('util.php', $contents);
shell: php {0}
- run: git fetch --depth=1 --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
shell: bash
- run: git diff --name-only origin/${{ github.base_ref }} -- '*.php' > ${GITHUB_ACTION_PATH}/paths
shell: bash
- run: cat ${GITHUB_ACTION_PATH}/paths
shell: bash
# head
- run: php ${GITHUB_ACTION_PATH}/php-ast-hashes.php ${version} ${GITHUB_ACTION_PATH}/paths ${GITHUB_ACTION_PATH}/head
env:
version: ${{ inputs.ast-version }}
shell: bash
- run: cat ${GITHUB_ACTION_PATH}/head
shell: bash
# base
- run: git switch ${{ github.base_ref }}
shell: bash
- run: php ${GITHUB_ACTION_PATH}/php-ast-hashes.php ${version} ${GITHUB_ACTION_PATH}/paths ${GITHUB_ACTION_PATH}/base
env:
version: ${{ inputs.ast-version }}
shell: bash
- run: cat ${GITHUB_ACTION_PATH}/base
shell: bash
# check
- id: diff
run: |
if diff ${GITHUB_ACTION_PATH}/base ${GITHUB_ACTION_PATH}/head; then
echo "::set-output name=exists::false"
else
echo "::set-output name=exists::true"
fi
shell: bash
branding:
icon: 'alert-octagon'
color: 'gray-dark'