-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yaml
79 lines (79 loc) · 3.16 KB
/
action.yaml
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
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@v6
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,
}));
require('fs').appendFileSync(process.env.GITHUB_OUTPUT, `sha=${pr.data.merge_commit_sha}\n`);
# 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: Checkout Head Sha
uses: actions/checkout@v4
with:
ref: ${{ steps.sha.outputs.sha }}
fetch-depth: 1
path: .wyrihaximus-composer.lock-diff/checkout/sha-sha
- name: Checkout Base Ref
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 1
path: .wyrihaximus-composer.lock-diff/checkout/base-ref
- name: Generate Comments
uses: docker://ghcr.io/wyrihaximus/github-action-composer.lock-diff:main
with:
dryRun: ${{ inputs.dryRun }}
workingDirectory: ${{ inputs.workingDirectory }}