diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml new file mode 100644 index 0000000..04a9992 --- /dev/null +++ b/.github/workflows/develop.yml @@ -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] }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 9f013d4..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,86 +0,0 @@ -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 }} - - merge: - needs: [matrix, build] - outputs: - json: ${{ steps.meta.outputs.json }} - strategy: - matrix: - node: ${{ fromJson(needs.matrix.outputs.node_types) }} - runs-on: ubuntu-latest - env: - REGISTRY_IMAGE: ${{ vars.REGISTRY }}/aiblockofficial/node-${{ matrix.node }} - steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-${{matrix.node}}-* - merge-multiple: true - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - tags: | - type=raw,value=latest - type=sha - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ vars.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Create manifest list and push - working-directory: /tmp/digests - run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} - - scan-image: - needs: [ matrix, build, merge] - strategy: - matrix: - node: ${{ fromJson(needs.matrix.outputs.node_types) }} - uses: aiblockofficial/workflows/.github/workflows/scan-image.yml@main - secrets: inherit - with: - IMAGE: ${{ fromJson(needs.merge.outputs.json).tags[0] }} \ No newline at end of file diff --git a/.github/workflows/node-build.yml b/.github/workflows/node-build.yml index edfd5c0..739729c 100644 --- a/.github/workflows/node-build.yml +++ b/.github/workflows/node-build.yml @@ -14,7 +14,7 @@ env: jobs: build: - name: Build local context + name: Build & Push runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/slack-msg.yml b/.github/workflows/slack-msg.yml index 01d2a87..c2bf4cb 100644 --- a/.github/workflows/slack-msg.yml +++ b/.github/workflows/slack-msg.yml @@ -9,6 +9,9 @@ on: info: required: true type: string + url: + required: true + type: string secrets: webhook: required: true @@ -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" } } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 545deb5..ec14b6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} \ No newline at end of file