Push marqo-base img to dev ECR #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push marqo-base img to dev ECR | |
on: | |
workflow_dispatch: | |
inputs: | |
marqo_base_ref: | |
description: 'marqo-base branch-name, commit SHA or tag' | |
required: true | |
default: 'main' | |
image_tag: | |
description: 'Image tag' | |
required: true | |
jobs: | |
Start-Runner: | |
name: Start self-hosted EC2 runner | |
runs-on: ubuntu-latest | |
outputs: | |
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 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_EC2_GH_RUNNER_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_EC2_GH_RUNNER_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Start EC2 runner | |
id: start-ec2-runner | |
uses: machulav/ec2-github-runner@fcfb31a5760dad1314a64a0e172b78ec6fc8a17e # v2.3.6 | |
with: | |
mode: start | |
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
# 200 GB amd64 image | |
ec2-image-id: ${{ secrets.AWS_IMG_BUILDER_AMI }} | |
ec2-instance-type: t3.xlarge | |
subnet-id: ${{ secrets.AWS_IMG_BUILDER_SUBNET_ID }} | |
security-group-id: ${{ secrets.AWS_IMG_BUILDER_SEC_GROUP_ID }} | |
Docker-Build: | |
name: Build docker image | |
needs: Start-Runner # required to start the main job when the runner is ready | |
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner | |
environment: marqo-build-environment | |
steps: | |
- name: Checkout marqo-base | |
uses: actions/checkout@v3 | |
with: | |
repository: marqo-ai/marqo-base | |
ref: ${{ github.event.inputs.marqo_base_ref }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.ECR_PUSHER_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.ECR_PUSHER_AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to ECR | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.ECR_DEV_MARQO_BASE_REGISTRY }}/marqo-base | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ secrets.ECR_DEV_MARQO_BASE_REGISTRY }}/marqo-base:${{ github.event.inputs.image_tag }} | |
Stop-Runner: | |
name: Stop self-hosted EC2 runner | |
needs: | |
- Start-Runner # required to get output from the start-runner job | |
- Docker-Build # required to wait when the main job is done | |
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@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_EC2_GH_RUNNER_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_EC2_GH_RUNNER_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Stop EC2 runner | |
uses: machulav/ec2-github-runner@fcfb31a5760dad1314a64a0e172b78ec6fc8a17e # v2.3.6 | |
with: | |
mode: stop | |
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
label: ${{ needs.start-runner.outputs.label }} | |
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |