tag-holesky-0.2.0 #34
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: Build and Publish Docker Images | |
# on: workflow_dispatch | |
on: | |
push: | |
tags: | |
- '**' | |
branches: | |
- main | |
- develop | |
- docker | |
- tag-holesky | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: false | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
name: Build Docker Image | |
runs-on: nix-128g | |
strategy: | |
fail-fast: false | |
matrix: | |
image: [worker] | |
include: | |
- image: worker | |
docker_file: docker/worker/Dockerfile | |
platform: linux/amd64 | |
environment: CI | |
steps: | |
- name: Cleanup docker build cache | |
run: | | |
docker system prune --force | |
docker builder prune --all --force | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up SSH key | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Build and push images | |
env: | |
DOCKER_BUILDKIT: 1 | |
run: | | |
TAG=$(echo ${{ github.ref_name }} | tr "[]/" -) | |
docker build \ | |
-t ${{ matrix.image }}:${{ github.sha }} \ | |
-f ${{ matrix.docker_file }} . \ | |
--platform ${{ matrix.platform }} \ | |
--ssh default \ | |
--build-arg INSTRUCTION_SET="x86-64-v3" | |
private-push: | |
name: Push Docker Images to AWS | |
environment: CI | |
runs-on: nix-128g | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
environment: [dev, test, prod] | |
image: [worker] | |
include: | |
- environment: dev | |
aws_account_id: ${{ vars.ZKMR_DEV_AWS_ACCOUNT_ID }} | |
- environment: test | |
aws_account_id: ${{ vars.ZKMR_TEST_AWS_ACCOUNT_ID }} | |
- environment: prod | |
aws_account_id: ${{ vars.ZKMR_PROD_AWS_ACCOUNT_ID }} | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ matrix.aws_account_id }}:role/github-actions-ecr-access-role | |
role-session-name: github-actions-ecr-access-role | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Push to ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
TAG=$(echo ${{ github.ref_name }} | tr "[]/" -) | |
docker tag ${{ matrix.image }}:${{ github.sha }} $ECR_REGISTRY/${{ matrix.image }}:${{ github.sha }} | |
docker tag ${{ matrix.image }}:${{ github.sha }} $ECR_REGISTRY/${{ matrix.image }}:${TAG} | |
docker push $ECR_REGISTRY/${{ matrix.image }}:${{ github.sha }} | |
docker push $ECR_REGISTRY/${{ matrix.image }}:${TAG} | |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then | |
docker tag ${{ matrix.image }}:${{ github.sha }} $ECR_REGISTRY/${{ matrix.image }}:latest | |
docker push $ECR_REGISTRY/${{ matrix.image }}:latest | |
fi | |
if [[ ${{ github.ref }} == 'refs/tags/v'* ]]; then | |
docker tag ${{ matrix.image }}:${{ github.sha }} $ECR_REGISTRY/${{ matrix.image }}:${TAG} | |
docker push $ECR_REGISTRY/${{ matrix.image }}:${TAG} | |
fi | |
public-push: | |
name: Push Docker Images to Docker hub | |
environment: CI | |
runs-on: nix-128g | |
needs: build | |
steps: | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to public repo | |
run: | | |
TAG=$(echo ${{ github.ref_name }} | tr "[]/" -) | |
docker tag worker:${{ github.sha }} lagrangelabs/worker:holesky | |
docker push lagrangelabs/worker:holesky | |
if [[ ${{ github.ref }} == 'refs/tags/v'* ]]; then | |
docker tag worker:${{ github.sha }} lagrangelabs/worker:latest | |
docker tag worker:${{ github.sha }} lagrangelabs/worker:${TAG} | |
docker push lagrangelabs/worker:latest | |
docker push lagrangelabs/worker:${TAG} | |
fi |