Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore tagging release images #55

Merged
merged 24 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f388291
chore: stash
deowk Apr 23, 2024
5286c69
Merge branch 'develop' into chore_tagging-release-images
deowk Apr 24, 2024
24adc76
chore: pass tag to workflow
deowk Apr 24, 2024
0dce2a7
chore: update main worflow to build for all node_types
deowk Apr 24, 2024
59852c1
chore: test trigger
deowk Apr 24, 2024
0e8ebeb
chore: move node build workflow into network
deowk Apr 24, 2024
df613ad
chore: update scan-image job
deowk Apr 25, 2024
bb47acf
chore: use correct pattern when downloading artifacts
deowk Apr 25, 2024
7532b2b
chore: get correct tag for image scanning
deowk Apr 25, 2024
8394ad7
chore: get correct tag for image scanning
deowk Apr 25, 2024
36ff1d0
chore: add slack notifications for image build and push
deowk Apr 26, 2024
46e0731
chore: update step reference in manifest
deowk Apr 26, 2024
7bb8585
chore: attempting to fix tags access
deowk Apr 26, 2024
d774f24
chore: set output from reusable node manifest workflow
deowk Apr 26, 2024
8fcb94f
chore: move notifications and scanning into reusable workflow
deowk Apr 26, 2024
230d0d7
chore: reusability refactor
deowk Apr 26, 2024
79bfbe6
chore: move workflows to top level
deowk Apr 26, 2024
50fd536
chore: more descriptive name for build and push
deowk Apr 26, 2024
733b443
chore: more descriptive name for build and push...again
deowk Apr 26, 2024
cb1b20e
chore: secrets inherit
deowk Apr 26, 2024
68de959
chore: better naming
deowk Apr 26, 2024
3746dc8
chore: update manual build
deowk Apr 29, 2024
4c514d6
chore: update release build to add version tag
deowk Apr 29, 2024
99574f3
chore: remove test workflow trigger
deowk Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: build-push-scan

on:
push:
branches:
- develop

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

jobs:
build-and-push:
uses: ./.github/workflows/node-build-and-push-all.yml
secrets: inherit

26 changes: 0 additions & 26 deletions .github/workflows/main.yml

This file was deleted.

12 changes: 10 additions & 2 deletions .github/workflows/manual-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ permissions:

jobs:
build:
uses: aiblockofficial/workflows/.github/workflows/node-build.yml@main
uses: ./.github/workflows/node-build.yml
with:
REGISTRY: ${{ vars.REGISTRY }}
REPOSITORY: ${{ vars.REPOSITORY }}
NODE_TYPE: ${{ inputs.node_type }}
secrets: inherit

manifest:
needs: [build]
uses: ./.github/workflows/node-manifest.yml
with:
REGISTRY: ${{ vars.REGISTRY }}
NODE_TYPE: ${{ inputs.node_type }}
secrets: inherit
42 changes: 42 additions & 0 deletions .github/workflows/node-build-and-push-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: node-build-and-push-all

on:
workflow_call:
inputs:
TAG:
required: false
type: string
default: "latest"

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 }}
secrets: inherit

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 }}
TAG: ${{ inputs.TAG }}
secrets: inherit
81 changes: 81 additions & 0 deletions .github/workflows/node-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: node-build

on:
workflow_call:
inputs:
REGISTRY:
required: true
type: string
NODE_TYPE:
required: false
type: string
default: "mempool"

env:
REGISTRY_IMAGE: ${{ inputs.REGISTRY }}/aiblockofficial/node-${{ inputs.NODE_TYPE }}

jobs:
build:
name: Build & Push [${{ inputs.NODE_TYPE }}] (${{ matrix.platform}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

- name: Check out the repo
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup docker buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
# if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ inputs.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push A-Block node by digest
id: build
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
NODE_TYPE_ARG=${{ inputs.NODE_TYPE }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{inputs.NODE_TYPE}}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
77 changes: 77 additions & 0 deletions .github/workflows/node-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: node-manifest

on:
workflow_call:
inputs:
REGISTRY:
required: true
type: string
NODE_TYPE:
required: false
type: string
default: "mempool"
TAG:
required: false
type: string
default: "latest"

env:
REGISTRY_IMAGE: ${{ inputs.REGISTRY }}/aiblockofficial/node-${{ inputs.NODE_TYPE }}

jobs:
create-and-push-manifest:
name: Create & Push Manifest [${{ inputs.NODE_TYPE }}]
outputs:
json: ${{ steps.meta.outputs.json }}
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{inputs.NODE_TYPE}}-*
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=${{ inputs.TAG }}
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 }}

slack-notification:
name: Slack Notify [${{ inputs.NODE_TYPE }}]
needs: [create-and-push-manifest]
if: always()
uses: ./.github/workflows/slack-msg.yml
with:
heading: ${{ contains(needs.*.result, 'failure') && 'Image Push Failed :red_circle:' || 'Image Push Success :large_green_circle:' }}
info: "IMAGE: *${{ join(fromJson(needs.create-and-push-manifest.outputs.json).tags, ', ') }}*"
url: ${{ github.server_url }}/${{ github.repository }}/pkgs/container/node-${{inputs.NODE_TYPE}}
secrets:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}

scan-image:
name: Scan Image [${{ inputs.NODE_TYPE }}]
needs: [create-and-push-manifest]
uses: aiblockofficial/workflows/.github/workflows/scan-image.yml@main
secrets: inherit
with:
IMAGE: ${{ fromJson(needs.create-and-push-manifest.outputs.json).tags[0] }}
24 changes: 17 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
name: build-and-push-miner

on:
release:
types: [published]
push:
tags: ["v*.*.*"]

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

jobs:
build:
uses: aiblockofficial/workflows/.github/workflows/node-build.yml@main
get-version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.vars.outputs.tag }}
steps:
- uses: actions/checkout@v2

- name: Set Version
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
release:
needs: get-version
uses: ./.github/workflows/node-build-and-push-all.yml
with:
REGISTRY: ${{ vars.REGISTRY }}
REPOSITORY: ${{ vars.REPOSITORY }}
NODE_TYPE: "miner"
TAG: ${{ needs.get-version.outputs.tag }}
secrets: inherit
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 }}
Loading