-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): API test image (#4266)
- Loading branch information
Showing
9 changed files
with
145 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Report Docker Build status to PR | ||
description: Create or update PR comment related to Docker build | ||
|
||
inputs: | ||
image-tag: | ||
description: Full image tag | ||
required: false | ||
build-status: | ||
description: Build status in short format | ||
required: false | ||
security-report-status: | ||
description: Security report status in short format | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: peter-evans/find-comment@v3 | ||
id: find-comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: 'Docker builds report' | ||
|
||
- uses: chuhlomin/[email protected] | ||
if: ${{ !inputs.image-tag }} | ||
id: render-header | ||
with: | ||
template: .github/docker_build_comment_template.md | ||
|
||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: ${{ !inputs.image-tag }} | ||
with: | ||
comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
edit-mode: replace | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: ${{ steps.render-header.outputs.result }} | ||
|
||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: ${{ inputs.image-tag }} | ||
with: | ||
comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
edit-mode: append | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: > | ||
| `${{ inputs.image-tag }}` | ${{ inputs.build-status }} | ${{ inputs.security-report-status }} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{{ .message }} | ||
#### Docker builds report | ||
|
||
| Image | Build Status | Security report | | ||
| --------------- | ------------------ | --------------------------- | | ||
| {{ .imageTag }} | {{ .buildStatus }} | {{ .securityReportStatus }} | | ||
| Image | Build Status | Security report | | ||
| ----- | ------------ | --------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,33 +96,6 @@ jobs: | |
${{ inputs.registry-url }}/flagsmith/${{ inputs.image-name }} | ||
tags: ${{ inputs.tags }} | ||
|
||
- uses: chuhlomin/[email protected] | ||
if: inputs.comment | ||
id: render-comment-initial | ||
with: | ||
template: .github/docker_build_comment_template.md | ||
vars: | | ||
message: "`${{ inputs.image-name }}` is being built... :hourglass_flowing_sand:" | ||
imageTag: "Pending :hourglass_flowing_sand:" | ||
buildStatus: "Building :hourglass_flowing_sand:" | ||
securityReportStatus: "${{ inputs.scan && 'Pending :hourglass_flowing_sand:' || 'Skipped' }}" | ||
- uses: peter-evans/find-comment@v3 | ||
if: inputs.comment | ||
id: find-comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: '`${{ inputs.image-name }}` ' | ||
|
||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: inputs.comment | ||
id: add-comment | ||
with: | ||
comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
edit-mode: replace | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: ${{ steps.render-comment-initial.outputs.result }} | ||
|
||
- name: Build and push image | ||
id: build | ||
uses: depot/build-push-action@v1 | ||
|
@@ -156,23 +129,13 @@ jobs: | |
echo ::add-mask::$DEPOT_TOKEN | ||
echo depot-token=$DEPOT_TOKEN >> $GITHUB_OUTPUT | ||
- uses: chuhlomin/[email protected] | ||
if: inputs.comment | ||
id: render-comment-on-finished-build | ||
- name: Report build finish | ||
uses: ./.github/actions/docker-build-report-to-pr | ||
if: inputs.comment && !inputs.scan | ||
with: | ||
template: .github/docker_build_comment_template.md | ||
vars: | | ||
message: "`${{ inputs.image-name }}` image build finished :sparkles: ${{ inputs.scan && 'Executing security scan...' || '' }}" | ||
imageTag: "`${{ steps.image-tag.outputs.image-tag }}`" | ||
buildStatus: "Finished :white_check_mark:" | ||
securityReportStatus: "${{ inputs.scan && 'Pending :hourglass_flowing_sand:' || 'Skipped' }}" | ||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: inputs.comment | ||
with: | ||
comment-id: ${{ steps.add-comment.outputs.comment-id }} | ||
edit-mode: replace | ||
body: ${{ steps.render-comment-on-finished-build.outputs.result }} | ||
image-tag: ${{ steps.image-tag.outputs.image-tag }} | ||
build-status: 'Finished :white_check_mark:' | ||
security-report-status: 'Skipped' | ||
|
||
- name: Run Trivy vulnerability scanner | ||
id: trivy | ||
|
@@ -194,25 +157,17 @@ jobs: | |
|
||
- name: Render scan results URL | ||
id: scan-results-url | ||
if: inputs.scan | ||
run: > | ||
echo scan-results-url=${{ format('{0}/{1}/security/code-scanning?query=pr%3A{2}+path%3Aflagsmith%2F{3}', | ||
github.server_url, github.repository, github.event.pull_request.number, inputs.image-name) }} >> | ||
$GITHUB_OUTPUT | ||
- uses: chuhlomin/[email protected] | ||
id: render-comment-on-finished-scan | ||
if: inputs.scan && inputs.comment | ||
with: | ||
template: .github/docker_build_comment_template.md | ||
vars: | | ||
message: "`${{ inputs.image-name }}` image build and security scan finished :sparkles:" | ||
imageTag: "`${{ steps.image-tag.outputs.image-tag }}`" | ||
buildStatus: "Finished :white_check_mark:" | ||
securityReportStatus: "${{ format('[Results]({0}) :white_check_mark:', steps.scan-results-url.outputs.scan-results-url) }}" | ||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: inputs.scan && inputs.comment | ||
- name: Report scan results URL | ||
uses: ./.github/actions/docker-build-report-to-pr | ||
if: inputs.comment && inputs.scan | ||
with: | ||
comment-id: ${{ steps.add-comment.outputs.comment-id }} | ||
edit-mode: replace | ||
body: ${{ steps.render-comment-on-finished-scan.outputs.result }} | ||
image-tag: ${{ steps.image-tag.outputs.image-tag }} | ||
build-status: 'Finished :white_check_mark:' | ||
security-report-status: | ||
"${{ format('[Results]({0}) :white_check_mark:', steps.scan-results-url.outputs.scan-results-url) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.