Skip to content

Commit

Permalink
chore: add slack notifications for image build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
deowk committed Apr 26, 2024
1 parent 8394ad7 commit 36ff1d0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 100 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: build-scan

on:
push:
branches:
- develop
pull_request:
branches:
- "develop"

permissions:
contents: read
packages: write
security-events: write

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
node_types: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
run: |
echo "matrix=${{vars.NODE_TYPES}}" >> $GITHUB_OUTPUT
build:
needs: matrix
strategy:
matrix:
node: ${{ fromJson(needs.matrix.outputs.node_types) }}
uses: ./.github/workflows/node-build.yml
with:
REGISTRY: ${{ vars.REGISTRY }}
NODE_TYPE: ${{ matrix.node }}

manifest:
needs: [matrix, build]
strategy:
matrix:
node: ${{ fromJson(needs.matrix.outputs.node_types) }}
uses: ./.github/workflows/node-manifest.yml
with:
REGISTRY: ${{ vars.REGISTRY }}
NODE_TYPE: ${{ matrix.node }}

slack-notification:
needs: [matrix, build, manifest]
if: always()
strategy:
matrix:
node: ${{ fromJson(needs.matrix.outputs.node_types) }}
uses: ./.github/workflows/slack-msg.yml
with:
heading: ${{ contains(needs.*.result, 'failure') && 'Image Push Failed :red_circle:' || 'Image Push Success :large_green_circle:' }}
info: "IMAGES: *${{ fromJson(needs.manifest.outputs.json).tags }}*"
url: ${{ github.server_url }}/${{ github.repository }}/pkgs/container/node-${{matrix.node}}
secrets:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}

scan-image:
needs: [matrix, build, manifest]
strategy:
matrix:
node: ${{ fromJson(needs.matrix.outputs.node_types) }}
uses: aiblockofficial/workflows/.github/workflows/scan-image.yml@main
secrets: inherit
with:
IMAGE: ${{ fromJson(needs.manifest.outputs.json).tags[0] }}
86 changes: 0 additions & 86 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/node-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

jobs:
build:
name: Build local context
name: Build & Push
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/slack-msg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
info:
required: true
type: string
url:
required: true
type: string
secrets:
webhook:
required: true
Expand Down Expand Up @@ -45,7 +48,7 @@ jobs:
"emoji": true
},
"value": "click_me_123",
"url": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"url": "${{ inputs.url }}",
"action_id": "button-action"
}
}
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ jobs:
timeout-minutes: 30
run: cargo test --release -- --test-threads=1

slack-notification-success:
slack-notification:
needs: integration-tests
if: success()
if: always()
uses: ./.github/workflows/slack-msg.yml
with:
heading: "Tests Passed :large_green_circle:"
info: "PR: *${{ github.event.pull_request.title }}* / Branch: *${{ github.event.pull_request.head.ref }}*"
secrets:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
slack-notification-failure:
needs: integration-tests
if: failure()
uses: ./.github/workflows/slack-msg.yml
with:
heading: "Tests Failed :red_circle:"
heading: ${{ contains(needs.*.result, 'failure') && 'Tests Failed :red_circle:' || 'Tests Passed :large_green_circle:' }}
info: "PR: *${{ github.event.pull_request.title }}* / Branch: *${{ github.event.pull_request.head.ref }}*"
url: "${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
secrets:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 36ff1d0

Please sign in to comment.