Skip to content

Commit b29470e

Browse files
authored
chore(greenhouse): add long SHA to Greenhouse release to fix image scan error and report failing steps (#1091)
* chore(greenhouse): adds long sha as a tag to the release * chore(ci): test workflow with failing jobs * chore(ci): adds outcome * chore(ci): ouput the right var * chore(ci): extends message with failing jobs * chore(ci): removes tests
1 parent cd2a9c7 commit b29470e

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

.github/workflows/build-push-greenhouse-image.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
build-and-push:
3232
name: Build and Push Greenhouse Dashboard Image
3333
runs-on: [default]
34-
34+
outputs:
35+
failed: ${{ steps.set-failure-output.outputs.failed }}
3536
permissions:
3637
contents: read
3738
packages: write
@@ -92,6 +93,7 @@ jobs:
9293
tags: |
9394
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ steps.read_version.outputs.IMAGE_VERSION }}
9495
type=sha,enable=true,format=short,prefix=
96+
type=raw,value=${{ github.sha }}
9597
labels: |
9698
org.opencontainers.image.description=${{env.DESCRIPTION}}
9799
org.opencontainers.image.title=Greenhouse-UI
@@ -124,6 +126,11 @@ jobs:
124126
# against the sigstore community Fulcio instance.
125127
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
126128

129+
- name: Set failure output
130+
id: set-failure-output
131+
if: failure()
132+
run: echo "failed=build-and-push" >> $GITHUB_OUTPUT
133+
127134
vulnerability-scan:
128135
permissions:
129136
contents: read
@@ -132,6 +139,8 @@ jobs:
132139
name: Vulnerability Scan
133140
needs: build-and-push
134141
runs-on: [default]
142+
outputs:
143+
failed: ${{ steps.set-failure-output.outputs.failed }}
135144
steps:
136145
- name: Run Trivy vulnerability scanner
137146
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 # 0.31.0
@@ -163,6 +172,11 @@ jobs:
163172
with:
164173
sarif_file: trivy-results.sarif
165174

175+
- name: Set failure output
176+
id: set-failure-output
177+
if: failure()
178+
run: echo "failed=vulnerability-scan" >> $GITHUB_OUTPUT
179+
166180
notify-on-failure:
167181
if: failure()
168182
permissions:
@@ -171,6 +185,13 @@ jobs:
171185
uses: cloudoperators/juno/.github/workflows/shared-slack-notification.yaml@main
172186
with:
173187
title: "🚨 JUNO Greenhouse Image Failed 🚨"
174-
body: "An error occurred while building the Greenhouse image for the branch ${{ github.head_ref || github.ref_name }}. Please check the logs for more information. <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Check the logs>"
188+
body: |
189+
An error occurred while building the Greenhouse image for the branch `${{ github.head_ref || github.ref_name }}`.
190+
191+
❌ Failing jobs:
192+
- ${{ needs.build-and-push.outputs.failed }}
193+
- ${{ needs.vulnerability-scan.outputs.failed }}
194+
195+
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Check the logs>
175196
secrets:
176197
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/build-push-supernova-image.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
build-and-push:
2727
name: Build and push Supernova image
2828
runs-on: [default]
29-
29+
outputs:
30+
failed: ${{ steps.set-failure-output.outputs.failed }}
3031
permissions:
3132
contents: read
3233
packages: write
@@ -143,16 +144,22 @@ jobs:
143144
# against the sigstore community Fulcio instance.
144145
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
145146

147+
- name: Set failure output
148+
id: set-failure-output
149+
if: failure()
150+
run: echo "failed=build-and-push" >> $GITHUB_OUTPUT
151+
146152
vulnerability-scan:
147153
if: success()
148154
permissions:
149155
contents: read
150156
packages: read
151157
security-events: write
152-
153158
name: Vulnerability Scan
154159
needs: build-and-push
155160
runs-on: [default]
161+
outputs:
162+
failed: ${{ steps.set-failure-output.outputs.failed }}
156163
steps:
157164
- name: Run Trivy vulnerability scanner
158165
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 # 0.31.0
@@ -184,6 +191,11 @@ jobs:
184191
with:
185192
sarif_file: trivy-results.sarif
186193

194+
- name: Set failure output
195+
id: set-failure-output
196+
if: failure()
197+
run: echo "failed=vulnerability-scan" >> $GITHUB_OUTPUT
198+
187199
notify-on-failure:
188200
if: failure()
189201
permissions:
@@ -192,6 +204,13 @@ jobs:
192204
uses: cloudoperators/juno/.github/workflows/shared-slack-notification.yaml@main
193205
with:
194206
title: "🚨 JUNO Supernova Image Failed 🚨"
195-
body: "An error occurred while building the Supernova image for the branch ${{ github.head_ref || github.ref_name }}. Please check the logs for more information. <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Check the logs>"
207+
body: |
208+
An error occurred while building the Supernova image for the branch `${{ github.head_ref || github.ref_name }}`.
209+
210+
❌ Failing jobs:
211+
- ${{ needs.build-and-push.outputs.failed }}
212+
- ${{ needs.vulnerability-scan.outputs.failed }}
213+
214+
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Check the logs>
196215
secrets:
197216
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)