Skip to content

Commit

Permalink
Add labels to EC2 build machines. Refactor actions to reduce duplicat…
Browse files Browse the repository at this point in the history
…e start ec2 runner actions. (#7119)

As the title.

I also took the chance to compose the actions, instead of injecting it everywhere.
  • Loading branch information
davinchia authored Oct 19, 2021
1 parent 1441bf9 commit 214b158
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 84 deletions.
56 changes: 56 additions & 0 deletions .github/actions/start-aws-runner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Runner Start (AWS)'
description: 'Starting Runner on AWS Cloud'
inputs:
aws-access-key-id:
required: true
aws-secret-access-key:
required: true
github-token:
required: true
ec2-image-id:
default: 'ami-04bd6e81239f4f3fb'
required: true
ec2-instance-type:
default: 'c5.2xlarge'
required: true
subnet-id:
default: 'subnet-0469a9e68a379c1d3'
required: true
security-group-id:
default: 'sg-0793f3c9413f21970'
required: true
label:
required: false
ec2-instance-id:
required: false
outputs:
label:
value: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id:
value: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}

runs:
using: "composite"
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: us-east-2
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.2.1
with:
mode: start
github-token: ${{ inputs.github-token }}
ec2-image-id: ${{ inputs.ec2-image-id }}
ec2-instance-type: ${{ inputs.ec2-instance-type }}
subnet-id: ${{ inputs.subnet-id }}
security-group-id: ${{ inputs.security-group-id }}
aws-resource-tags: >
[
{"Key": "BuildType", "Value": "oss"},
{"Key": "Repository", "Value": "${{ github.repository }}"},
{"Key": "Branch", "Value": "${{ github.ref }}"}
]
18 changes: 6 additions & 12 deletions .github/workflows/gke-kube-test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,15 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.3.0
with:
mode: start
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-04bd6e81239f4f3fb
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
gke-kube-acceptance-test:
# In case of self-hosted EC2 errors, removed the `needs` line and switch back to running on ubuntu-latest.
needs: start-gke-kube-acceptance-test-runner # required to start the main job when the runner is ready
Expand All @@ -47,6 +40,7 @@ jobs:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
> :clock2: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: Checkout Airbyte
uses: actions/checkout@v2

Expand Down
68 changes: 20 additions & 48 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,15 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 Runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.3.0
with:
mode: start
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-04bd6e81239f4f3fb
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970

ensure-images-exist:
name: "Ensure all required Docker images exist on Dockerhub"
Expand Down Expand Up @@ -171,22 +164,15 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 Runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.3.0
with:
mode: start
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-04bd6e81239f4f3fb
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
platform-build:
# In case of self-hosted EC2 errors, remove the next two lines and uncomment the currently commented out `runs-on` line.
needs: start-platform-build-runner # required to start the main job when the runner is ready
Expand Down Expand Up @@ -330,22 +316,15 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 Runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.3.0
with:
mode: start
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-04bd6e81239f4f3fb
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
frontend-test:
needs: start-frontend-test-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-frontend-test-runner.outputs.label }} # run the job on the newly created runner
Expand Down Expand Up @@ -422,22 +401,15 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2.3.0
with:
mode: start
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-0d4083c04fde515c4
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
kube-acceptance-test:
# In case of self-hosted EC2 errors, removed the `needs` line and switch back to running on ubuntu-latest.
needs: start-kube-acceptance-test-runner # required to start the main job when the runner is ready
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/publish-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 Runner
repository: ${{github.event.pull_request.head.repo.full_name}} # always use the branch's repository
- name: Start AWS Runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
uses: ./.github/actions/start-aws-runner
with:
mode: start
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-0d648081937c75a73
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
publish-image:
needs: start-publish-image-runner
runs-on: ${{ needs.start-publish-image-runner.outputs.label }}
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- name: Checkout Airbyte
uses: actions/checkout@v2
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 Runner
repository: ${{ github.event.inputs.repo }}
- name: Start AWS Runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
uses: ./.github/actions/start-aws-runner
with:
mode: start
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ secrets.SELF_RUNNER_GITHUB_ACCESS_TOKEN }}
ec2-image-id: ami-0d648081937c75a73
ec2-instance-type: c5.2xlarge
subnet-id: subnet-0469a9e68a379c1d3
security-group-id: sg-0793f3c9413f21970
integration-test:
timeout-minutes: 240
needs: start-test-runner
Expand Down

0 comments on commit 214b158

Please sign in to comment.