Skip to content

Commit 507008f

Browse files
ci: Send email if the reproducible build process fails
Changelog-None.
1 parent 2791c60 commit 507008f

File tree

1 file changed

+96
-25
lines changed

1 file changed

+96
-25
lines changed

.github/workflows/repro.yml

+96-25
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,80 @@ jobs:
1717
version: ['focal', 'jammy', 'noble']
1818
steps:
1919
- name: Git checkout
20+
id: repo_chackout
2021
uses: actions/checkout@v4
2122

22-
- name: Build environment setup
23+
- name: Build environment setup - ${{ matrix.version }}
24+
id: environment_setup
25+
shell: bash
2326
run: |
2427
echo "Building base image for ${{ matrix.version }}"
25-
sudo docker run --rm -v $(pwd):/build ubuntu:${{ matrix.version }} bash -c "\
26-
apt-get update && \
27-
apt-get install -y debootstrap && \
28-
debootstrap ${{ matrix.version }} /build/${{ matrix.version }}"
29-
sudo tar -C ${{ matrix.version }} -c . | docker import - ${{ matrix.version }}
28+
{
29+
echo "STEP=Build environment setup" >> "$GITHUB_ENV"
30+
sudo docker run --rm -v $(pwd):/build ubuntu:${{ matrix.version }} bash -c "\
31+
apt-get update && \
32+
apt-get install -y debootstrap && \
33+
debootstrap ${{ matrix.version }} /build/${{ matrix.version }}"
34+
sudo tar -C ${{ matrix.version }} -c . | docker import - ${{ matrix.version }}
35+
} > command.log 2>&1 || {
36+
echo "ERROR<<EOF" >> "$GITHUB_ENV"
37+
echo "$(cat command.log)" >> "$GITHUB_ENV"
38+
echo "EOF" >> "$GITHUB_ENV"
39+
exit 1
40+
}
3041
31-
- name: Builder image setup
32-
run: docker build -t cl-repro-${{ matrix.version }} - < contrib/reprobuild/Dockerfile.${{ matrix.version }}
42+
- name: Builder image setup - ${{ matrix.version }}
43+
id: builder_image_setup
44+
shell: bash
45+
run: |
46+
{
47+
echo "STEP=Builder image setup" >> "$GITHUB_ENV"
48+
docker build -t cl-repro-${{ matrix.version }} - < contrib/reprobuild/Dockerfile.${{ matrix.version }}
49+
} > command.log 2>&1 || {
50+
echo "ERROR<<EOF" >> "$GITHUB_ENV"
51+
echo "$(cat command.log)" >> "$GITHUB_ENV"
52+
echo "EOF" >> "$GITHUB_ENV"
53+
exit 1
54+
}
3355
34-
- name: Build using the builder image and store Git state
56+
- name: Build reproducible image and store Git state - ${{ matrix.version }}
57+
id: repro_image_setup
58+
shell: bash
3559
run: |
36-
# Create release directory.
37-
mkdir $GITHUB_WORKSPACE/release
60+
{
61+
echo "STEP=Build reproducible image and store Git state" >> "$GITHUB_ENV"
3862
39-
# Perform the repro build.
40-
docker run --name cl-build -v $GITHUB_WORKSPACE:/repo -e FORCE_MTIME=$(date +%F) -t cl-repro-${{ matrix.version }}
63+
# Create release directory.
64+
mkdir $GITHUB_WORKSPACE/release
4165
42-
# Commit the image in order to inspect the build later.
43-
docker commit cl-build cl-release
66+
# Perform the repro build.
67+
docker run --name cl-build -v $GITHUB_WORKSPACE:/repo -e FORCE_MTIME=$(date +%F) -t cl-repro-${{ matrix.version }}
4468
45-
# Inspect the version.
46-
docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-release bash -c "make version > /repo/release/version.txt"
69+
# Commit the image in order to inspect the build later.
70+
docker commit cl-build cl-repro
4771
48-
# Inspect the Git tree state.
49-
docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-release bash -c "\
50-
git --no-pager status > /repo/release/git.log && \
51-
git --no-pager diff >> /repo/release/git.log"
72+
# Inspect the version.
73+
docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "make version > /repo/release/version.txt"
5274
53-
# Change permissions on the release files for access by the runner environment.
54-
sudo chown -R runner $GITHUB_WORKSPACE/release
75+
# Inspect the Git tree state.
76+
docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "\
77+
git --no-pager status > /repo/release/git.log && \
78+
git --no-pager diff >> /repo/release/git.log"
5579
56-
- name: Assert clean version and release
80+
# Change permissions on the release files for access by the runner environment.
81+
sudo chown -R runner $GITHUB_WORKSPACE/release
82+
} > command.log 2>&1 || {
83+
echo "ERROR<<EOF" >> "$GITHUB_ENV"
84+
echo "$(cat command.log)" >> "$GITHUB_ENV"
85+
echo "EOF" >> "$GITHUB_ENV"
86+
exit 1
87+
}
88+
89+
- name: Assert clean version - ${{ matrix.version }}
90+
id: assert_version
91+
shell: bash
5792
run: |
93+
echo "STEP=Assert clean version" >> "$GITHUB_ENV"
5894
echo 'Version:'
5995
cat release/version.txt
6096
echo -e
@@ -65,7 +101,7 @@ jobs:
65101
echo -e
66102
67103
if [ -n "$(cat release/version.txt | sed -n '/-modded/p')" ] || \
68-
[ -n "$(echo $releasefile | sed -n '/-modded/p')" ]
104+
[ -n "$(echo $releasefile | sed -n '/-modded/p')" ]
69105
then
70106
echo "Git Status and Diff:"
71107
cat release/git.log
@@ -76,3 +112,38 @@ jobs:
76112
else
77113
echo 'Success! Clean release.'
78114
fi
115+
116+
- name: Upload release artifact - ${{ matrix.version }}
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: release-${{ matrix.version }}
120+
path: release
121+
122+
- name: Send email on failure
123+
id: send_email
124+
if: ${{ failure() }}
125+
uses: dawidd6/action-send-mail@v3
126+
with:
127+
server_address: smtp.gmail.com
128+
server_port: 587
129+
username: ${{ secrets.EMAIL_USERNAME }}
130+
password: ${{ secrets.EMAIL_PASSWORD }}
131+
from: ${{ secrets.EMAIL_USERNAME }}
132+
to: ${{ vars.DISTRIBUTION_LIST }}
133+
subject: "CI Failure: Step ${{ env.STEP }} failed for distro ${{ matrix.version }}"
134+
convert_markdown: true
135+
html_body: |
136+
<html>
137+
<body>
138+
<p><strong>Failure Details:</strong></p>
139+
<ul>
140+
<li><strong>Workflow:</strong> ${{ github.workflow }}</li>
141+
<li><strong>Event:</strong> ${{ github.event_name }}</li>
142+
<li><strong>Job:</strong> ${{ github.job }}</li>
143+
<li><strong>Distro:</strong> ${{ matrix.version }}</li>
144+
<li><strong>Step:</strong> ${{ env.STEP }}</li>
145+
<li><strong>URL:</strong> <a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}</a></li>
146+
<li><strong>Reason:</strong> <pre>${{ env.ERROR }}</pre></li>
147+
</ul>
148+
</body>
149+
</html>

0 commit comments

Comments
 (0)