Skip to content

Commit

Permalink
Merge pull request #206 from tokamak-network/OR-1789--thanos-remove-e…
Browse files Browse the repository at this point in the history
…c2-runner-feature

[OR-1789] remove ec2 runner feature
  • Loading branch information
steven94kr authored Aug 7, 2024
2 parents 860f406 + 7ce12b3 commit 8cae7ee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 378 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Declares the repository safe and not under dubious ownership.
- name: Add repository to git safe directories
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-ts-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
id: filter
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Add repository to git safe directories
run: git config --global --add safe.directory $GITHUB_WORKSPACE

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
Expand All @@ -64,7 +64,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-qemu-action@v2
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/publish-genesis-rollup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
publish-genesis-rollup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'ap-northeast-2'
SOURCE_DIR: 'packages/tokamak/contracts-bedrock/genesis'
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'ap-northeast-2'
SOURCE_DIR: 'packages/tokamak/contracts-bedrock/genesis'
2 changes: 1 addition & 1 deletion .github/workflows/publish-tokamak-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
shell: bash
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Add repository to git safe directories
run: git config --global --add safe.directory $GITHUB_WORKSPACE
Expand Down
189 changes: 7 additions & 182 deletions .github/workflows/release-docker-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo "GITCOMMIT=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}

- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
echo "GITCOMMIT=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
Expand All @@ -147,72 +147,6 @@ jobs:
GITCOMMIT=${{ steps.build_args.outputs.GITCOMMIT }}
GITVERSION=${{ steps.build_args.outputs.GITVERSION }}
start-runners:
strategy:
matrix:
number: [0, 1, 2, 3, 4]
name: Start EC2 Runner
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.ACCESS_TOKEN }}
ec2-image-id: ami-0ceeb1418a9676af7
ec2-instance-type: m7g.2xlarge
subnet-id: subnet-0fb32a6561595a820
security-group-id: sg-06ecd9031cc2c8899
iam-role-name: ec2-runner
pre-runner-script: shutdown -P +40

- name: Runner status
id: status
run: |
echo "Runner label:" ${{ steps.start-ec2-runner.outputs.label }}
echo "EC2 instances id:" ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
- uses: cloudposse/github-action-matrix-outputs-write@main
id: out
with:
matrix-step-name: ${{ github.job }}
matrix-key: ${{ matrix.number }}
outputs: |-
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
runners:
name: EC2 Runner
needs: [start-runners]
runs-on: ubuntu-latest
outputs:
result: ${{ steps.read.outputs.result }}
steps:
- uses: cloudposse/github-action-matrix-outputs-read@main
id: read
with:
matrix-step-name: start-runners

ec2-update-arm64:
name: Update EC2 ${{ fromJson(needs.runners.outputs.result).ec2-instance-id[format('{0}', matrix.number)] }}
needs: [runners, version]
strategy:
matrix:
number: [0, 1, 2, 3, 4]
runs-on: ${{ fromJson(needs.runners.outputs.result).label[format('{0}', matrix.number)] }}
steps:
- name: update shutdown behavior
run: |
aws ec2 modify-instance-attribute --instance-initiated-shutdown-behavior terminate --instance-id ${{ fromJson(needs.runners.outputs.result).ec2-instance-id[format('{0}', matrix.number)] }}
chain-mon-amd64:
name: Publish ${{ matrix.target }}
needs: [version]
Expand All @@ -233,124 +167,15 @@ jobs:
username: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}

- name: Docker Image Name
id: docker-image-name
run: |
ARCHITECTURE=$(uname -m)
if [ "$ARCHITECTURE" = "x86_64" ]; then
ARCHITECTURE="amd64"
fi
if [ "$ARCHITECTURE" = "aarch64" ]; then
ARCHITECTURE="arm64"
fi
echo "docker-image-name=tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}-$ARCHITECTURE" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/docker/Dockerfile.packages
target: ${{ matrix.target }}
push: true
provenance: false
tags: ${{ steps.docker-image-name.outputs.docker-image-name }}

chain-mon-arm64:
name: Publish ${{ matrix.target }}
needs: [runners, ec2-update-arm64, version]
runs-on: ${{ fromJson(needs.runners.outputs.result).label[format('{0}', matrix.number)] }}
strategy:
matrix:
include:
- number: 0
target: fault-mon
- number: 1
target: balance-mon
- number: 2
target: drippie-mon
- number: 3
target: wd-mon
- number: 4
target: replica-mon
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}

- name: Docker Image Name
id: docker-image-name
run: |
ARCHITECTURE=$(uname -m)
if [ "$ARCHITECTURE" = "x86_64" ]; then
ARCHITECTURE="amd64"
fi
if [ "$ARCHITECTURE" = "aarch64" ]; then
ARCHITECTURE="arm64"
fi
echo "docker-image-name=tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}-$ARCHITECTURE" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: ./ops/docker/Dockerfile.packages
target: ${{ matrix.target }}
push: true
provenance: false
tags: ${{ steps.docker-image-name.outputs.docker-image-name }}

stop-runners:
name: Stop self-hosted EC2 runners
strategy:
matrix:
number: [0, 1, 2, 3, 4]
needs: [runners, chain-mon-arm64]
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.ACCESS_TOKEN }}
label: ${{ fromJson(needs.runners.outputs.result).label[format('{0}', matrix.number)] }}
ec2-instance-id: ${{ fromJson(needs.runners.outputs.result).ec2-instance-id[format('{0}', matrix.number)] }}

merge:
name: Build multi-arch images
needs: [version, chain-mon-amd64, chain-mon-arm64]
runs-on: ubuntu-latest
strategy:
matrix:
target: [fault-mon, balance-mon, drippie-mon, wd-mon, replica-mon]
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}

- name: Create and push manifest
uses: Noelware/docker-manifest-action@master
with:
inputs: tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}
images: tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}-amd64,tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}-arm64
push: true
tags: tokamaknetwork/thanos-${{ matrix.target }}:${{ needs.version.outputs.nightly-docker-tag }}

update-kustomize:
name: Update image version in kustomize manifest file(nightly)
Expand All @@ -362,15 +187,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: tokamak-network/tokamak-infra
ref: main
token: ${{ secrets.ACCESS_TOKEN }}
path: tokamak-infra

- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
uses: imranismail/setup-kustomize@v2
with:
github-token: ${{ secrets.ACCESS_TOKEN }}

Expand Down
Loading

0 comments on commit 8cae7ee

Please sign in to comment.