@@ -3,32 +3,86 @@ name: Generate Dockerfiles/patches
3
3
on :
4
4
push :
5
5
branches :
6
- - ' ** '
6
+ - master
7
7
tags-ignore :
8
8
- ' *'
9
9
pull_request :
10
+ paths :
11
+ - cpanfile
12
+ - config.yml
13
+ - generate.pl
14
+ - .github/workflows/generate-dockerfiles-patches.yml
10
15
11
16
jobs :
12
17
generate :
13
18
runs-on : ubuntu-latest
19
+ container : perl:devel
20
+ permissions :
21
+ contents : read
22
+ pull-requests : write
23
+
14
24
steps :
25
+ - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
26
+ with :
27
+ fetch-depth : 0
28
+
15
29
- name : Set up git user name and email
16
30
run : |
17
31
git config --global user.email "test@github-actions"
18
32
git config --global user.name "GitHub Actions"
19
- - uses : actions/checkout@master
20
- - name : Install system perl and cpanm
21
- run : |
22
- sudo apt-get install --no-install-recommends -y perl cpanminus
33
+
23
34
- name : Install dependencies
24
35
run : |
25
- cpanm --quiet --installdeps --notest -L local .
36
+ cpm install -g
37
+
26
38
- name : Generate Dockerfiles/patches
39
+ id : generate
40
+ shell : bash -euo pipefail -x {0}
27
41
run : |
28
- perl -Ilocal/lib/perl5 ./generate.pl
29
- - name : Show diffstat (if any)
30
- run : |
31
- git --no-pager diff --stat HEAD
32
- - name : Show diffstat (if any)
42
+ git config --global --add safe.directory $PWD
43
+ export DOCKER_PERL_DOWNLOADS_DIR=/tmp/docker-perl-downloads
44
+ perl ./generate.pl
45
+ /usr/bin/git --no-pager diff --stat > diffstat.txt
46
+ if [[ -s diffstat.txt ]]; then
47
+ echo has_extra_diffs=1 >> $GITHUB_OUTPUT
48
+ fi
49
+
50
+ - name : Setup NodeJS in Perl container (for comment to PR)
51
+ if : github.event_name == 'pull_request' && steps.generate.outputs.has_extra_diffs
33
52
run : |
34
- git --no-pager diff --stat HEAD
53
+ if ! command -v node; then
54
+ curl -sL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
55
+ bash nodesource_setup.sh
56
+ apt-get install -y --no-install-recommends nodejs
57
+ npm install -g yarn
58
+ rm -fr /var/lib/apt/lists/* /var/lib/apt/cache/* nodesource_setup.sh
59
+ fi
60
+
61
+ - name : Comment diffstat of generated changes to PR (if any)
62
+ if : github.event_name == 'pull_request' && steps.generate.outputs.has_extra_diffs
63
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
64
+ with :
65
+ script : |
66
+ const fs = require('node:fs')
67
+ let out = fs.readFileSync('diffstat.txt', 'utf8').trim()
68
+
69
+ if (out && context.actor !== 'nektos/act') {
70
+ const output = `
71
+ #### :warning: Additional changes generated (missing in commit), see diffstat:
72
+ <details><summary>Show Output</summary>
73
+
74
+ \`\`\`diff
75
+ ${ out }
76
+ \`\`\`
77
+ </details>`
78
+
79
+ github.rest.issues.createComment({
80
+ issue_number: context.issue.number,
81
+ owner: context.repo.owner,
82
+ repo: context.repo.repo,
83
+ body: output
84
+ })
85
+ } else {
86
+ console.log(out)
87
+ }
88
+
0 commit comments