forked from WyriHaximus/github-action-composer.lock-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
100 lines (100 loc) · 4.15 KB
/
action.yaml
File metadata and controls
100 lines (100 loc) · 4.15 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: 'composer.lock Diff'
description: 'GitHub Action that diffs composer.lock between current branch and default branch'
branding:
icon: 'grid'
color: 'orange'
inputs:
dryRun:
description: Generate the comment contents, but don't make the actual comments, set to "yes" to activate, off by default.
required: false
default: 'no'
workingDirectory:
description: Directory to execute the diff generator in
required: false
default: ''
outputs:
production:
description: Changed production dependencies table
development:
description: Changed development dependencies table
runs:
using: "composite"
steps:
- name: Poke Pull Request to force Background Process generating a merged_commit_sha
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
id: sha
with:
result-encoding: string
retries: 3
script: |
let timeout = 500;
var pr = (await github.rest.pulls.get({
pull_number: context.payload.pull_request.number,
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
}));
while (timeout < 60000 && pr.data.merge_commit_sha == null) {
timeout *= 2;
await new Promise(r => setTimeout(r, timeout));
pr = (await github.rest.pulls.get({
pull_number: context.payload.pull_request.number,
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
}));
}
pr = (await github.rest.pulls.get({
pull_number: context.payload.pull_request.number,
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
}));
return pr.data.merge_commit_sha;
# const requests = Array.from({length: 8}, (v, i) => 500 * Math.pow(2, i)).map(timeout => resolveShaAfterTimeout(timeout));
# console.log(requests);
# const pr = await Promise.any(requests);
# requests.forEach(request => request.cancel());
# const resolveShaAfterTimeout = async function (timeout) {
# await new Promise(r => setTimeout(r, timeout));
# return await github.rest.pulls.get({
# pull_number: context.payload.pull_request.number,
# owner: context.payload.repository.owner.login,
# repo: context.payload.repository.name,
# });
# };
- name: Ensure Working Directory has a trailing slash when empty
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
id: workingDirectory
with:
result-encoding: string
retries: 3
script: |
const workingDirectory = '${{ inputs.workingDirectory }}';
if (workingDirectory == '') {
return workingDirectory;
} else {
return workingDirectory.replace(/\/\s*$/, '').concat('/');
}
- name: Checkout Head Sha
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ steps.sha.outputs.result }}
fetch-depth: 1
path: .wyrihaximus-composer.lock-diff/checkout/sha-sha
sparse-checkout-cone-mode: false
sparse-checkout: |
${{ steps.workingDirectory.outputs.result }}composer.json
${{ steps.workingDirectory.outputs.result }}composer.lock
- name: Checkout Base Ref
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 1
path: .wyrihaximus-composer.lock-diff/checkout/base-ref
sparse-checkout-cone-mode: false
sparse-checkout: |
${{ steps.workingDirectory.outputs.result }}composer.json
${{ steps.workingDirectory.outputs.result }}composer.lock
- name: Generate Comments
uses: docker://ghcr.io/wyrihaximus/github-action-composer.lock-diff:main
with:
dryRun: ${{ inputs.dryRun }}
workingDirectory: ${{ steps.workingDirectory.outputs.result }}