-
Notifications
You must be signed in to change notification settings - Fork 45
118 lines (100 loc) · 3.71 KB
/
build-buildspec-pr.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: build
on:
pull_request_target:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
git config --local user.email "[email protected]"
git config --local user.name "Reproducible Central CI"
git config --local advice.detachedHead false
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log into ghcr.io registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: List changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: Build from buildspec
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == *.buildspec ]]; then
. $file
if [[ "$command" == SHELL* ]]
then
# don't even try to automatically build, but prepare message for PR comment
echo "command=$command"
echo "Configured build command requires interactive shell:
\`\`\`
command=$command
\`\`\`
Run
\`\`\`
git switch $artifactId-$version
./rebuild.sh $file
( ... interactive shell ... )
git add $(dirname $file)
git commit -m './rebuild.sh $file'
git push
gh pr merge -m
\`\`\`" >> PRcomment.txt
cat PRcomment.txt
continue
fi
sudo apt-get -qq install -y dos2unix 2>&1 > /dev/null
./rebuild.sh $file
bin/update-project-summary.sh "$(dirname $file)"
git add "$(dirname $file)"
git commit -m "./rebuild.sh $file"
git push
buildcompare="$(dirname $file)/$(basename $buildinfo .buildinfo).buildcompare"
echo '```' >> PRcomment.txt
grep -v okFiles "$buildcompare" >> PRcomment.txt
echo '```' >> PRcomment.txt
if [ $(grep "ko=0" PRcomment.txt | wc -l) -eq 0 ]
then
./build_diffoscope.sh "$buildcompare" buildcache/$artifactId
diffoscope="$(dirname $file)/$(basename $buildinfo .buildinfo).diffoscope"
[ -f $diffoscope ] && mv "$diffoscope" . \
&& echo ":mag: diffoscope analysis uploaded to ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> PRcomment.txt
fi
echo '```' >> PRcomment.txt
cat time.txt >> PRcomment.txt
echo '```' >> PRcomment.txt
rm -f time.txt
fi
done
- name: Add PR comment with results
if: ${{ hashFiles('PRcomment.txt') != '' }}
uses: mshick/add-pr-comment@v2
with:
message-path: |
PRcomment.txt
- name: Merge PR
if: ${{ hashFiles('PRcomment.txt') != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ $(grep "ko=0" PRcomment.txt | wc -l) -eq 1 ]
then
gh pr merge -m -d
fi
- name: Archive diffoscope output
if: ${{ hashFiles('*.diffoscope') != '' }}
uses: actions/upload-artifact@v4
with:
name: diffoscope
path: "*.diffoscope"