Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Update GHA workflows to use ephemeral ec2 runners
Browse files Browse the repository at this point in the history
The hardware we were previously using for multi-arch builds is being
end-of-lifed so this is the next best solution.

Signed-off-by: Ryan Beck-Buysse <rbuysse@bitwise.io>
  • Loading branch information
rbuysse committed Jun 13, 2022
1 parent 2b77df3 commit 3cea883
Show file tree
Hide file tree
Showing 3 changed files with 355 additions and 6 deletions.
80 changes: 79 additions & 1 deletion .github/workflows/grid-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,54 @@ on:
- push
- workflow_dispatch
jobs:
start_cluster:
if: github.repository == 'hyperledger/grid'
name: Start buildx cluster
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start_buildx_cluster.outputs.label }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Start EC2 runner
id: start_buildx_cluster
uses: ./.github/actions/ec2-runners
with:
action: start
amd_ami_id: ${{ secrets.AMD_AMI_ID }}
amd_instance_type: ${{ secrets.AMD_INSTANCE_TYPE }}
arm_ami_id: ${{ secrets.ARM_AMI_ID }}
arm_instance_type: ${{ secrets.ARM_INSTANCE_TYPE }}
gh_personal_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
security_group_id: ${{ secrets.SECURITY_GROUP_ID }}
subnet: ${{ secrets.SUBNET }}

- name: Output label
run: echo ${{ steps.start_buildx_cluster.outputs.label }}

- name: Notify Slack of Failure
if: cancelled() || failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

build_grid_dev:
if: github.repository == 'hyperledger/grid'
name: Build grid-dev
runs-on: macos-arm
needs: start_cluster
runs-on: ${{ needs.start_cluster.outputs.label }}
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
Expand All @@ -31,3 +75,37 @@ jobs:
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

stop_cluster:
name: Stop buildx cluster
needs:
- start_cluster
- build_grid_dev
runs-on: ubuntu-latest
if: ${{ github.repository == 'hyperledger/grid' && always() }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Destroy cluster
uses: ./.github/actions/ec2-runners
with:
action: stop
label: ${{ needs.start_cluster.outputs.label }}

- name: Notify Slack of Failure
if: cancelled() || failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
195 changes: 192 additions & 3 deletions .github/workflows/publish-docker-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,56 @@ concurrency:
cancel-in-progress: true

jobs:
publish_docker_images:
start_cluster_nightly:
if: >-
github.repository_owner == 'hyperledger'
runs-on: macos-arm
name: Start buildx cluster
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-buildx-cluster.outputs.label }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Start EC2 runner
id: start-buildx-cluster
uses: ./.github/actions/ec2-runners
with:
action: start
amd_ami_id: ${{ secrets.AMD_AMI_ID }}
amd_instance_type: c6i.4xlarge
arm_ami_id: ${{ secrets.ARM_AMI_ID }}
arm_instance_type: c6g.4xlarge
gh_personal_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
security_group_id: ${{ secrets.SECURITY_GROUP_ID }}
subnet: ${{ secrets.SUBNET }}

- name: Output label
run: echo ${{ steps.start-buildx-cluster.outputs.label }}

- name: Notify Slack of Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

publish_docker_nightly:
if: >-
github.repository_owner == 'hyperledger'
needs:
- start_cluster_nightly
runs-on: ${{ needs.start_cluster_nightly.outputs.label }}
steps:
- name: Display envvars
run: env
Expand All @@ -31,13 +77,122 @@ jobs:
with:
fetch-depth: 0

- name: Publish main images to dockerhub
- name: Publish nightly images to dockerhub
run: docker buildx ls && ./ci/publish-docker nightly
env:
NAMESPACE: ${{ secrets.DOCKER_HUB_NAMESPACE }}/
VERSION: AUTO_STRICT
CARGO_TERM_COLOR: always

- name: Notify Slack of Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

stop_cluster_nightly:
if: ${{ github.repository == 'hyperledger/grid' && always() }}
name: Stop buildx cluster
needs:
- start_cluster_nightly
- publish_docker_nightly
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Destroy cluster
uses: ./.github/actions/ec2-runners
with:
action: stop
label: ${{ needs.start_cluster_nightly.outputs.label }}

- name: Notify Slack of Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

# --== experimental images ==--

start_cluster_experimental:
if: >-
github.repository_owner == 'hyperledger'
name: Start buildx cluster
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-buildx-cluster.outputs.label }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Start EC2 runner
id: start-buildx-cluster
uses: ./.github/actions/ec2-runners
with:
action: start
amd_ami_id: ${{ secrets.AMD_AMI_ID }}
amd_instance_type: c6i.4xlarge
arm_ami_id: ${{ secrets.ARM_AMI_ID }}
arm_instance_type: c6g.4xlarge
gh_personal_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
security_group_id: ${{ secrets.SECURITY_GROUP_ID }}
subnet: ${{ secrets.SUBNET }}

- name: Output label
run: echo ${{ steps.start-buildx-cluster.outputs.label }}

- name: Notify Slack of Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

publish_docker_experimental:
if: >-
github.repository_owner == 'hyperledger'
needs:
- start_cluster_experimental
runs-on: ${{ needs.start_cluster_experimental.outputs.label }}
steps:
- name: Display envvars
run: env

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Publish experimental images to dockerhub
run: docker buildx ls && ./ci/publish-docker experimental
env:
Expand All @@ -53,3 +208,37 @@ jobs:
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

stop_cluster_experimental:
if: ${{ github.repository == 'hyperledger/grid' && always() }}
name: Stop buildx cluster
needs:
- start_cluster_experimental
- publish_docker_experimental
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_BUILDX_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}

- uses: actions/checkout@v2

- name: Destroy cluster
uses: ./.github/actions/ec2-runners
with:
action: stop
label: ${{ needs.start_cluster_experimental.outputs.label }}

- name: Notify Slack of Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,job
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading

0 comments on commit 3cea883

Please sign in to comment.