Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker build and push on release #151

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/build_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build Geth Docker Image

on:
release:
types: [created]

jobs:
build-and-push-stage:
runs-on: ubuntu-latest
environment: stage
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set IMAGE_TAG
id: set_image_tag
run: |
echo "::set-output name=IMAGE_TAG::$(printf $GITHUB_REF_NAME | tr / -)"

- name: Build, tag, and push image to Amazon ECR
env:
IMAGE_TAG: ${{ steps.set_image_tag.outputs.IMAGE_TAG }}
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: geth
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} \
--build-arg COMMIT=${{ github.sha }} \
--build-arg VERSION=${IMAGE_TAG} \
--build-arg BUILDNUM=1 .
docker image push --all-tags $ECR_REGISTRY/$ECR_REPOSITORY

build-and-push-prod:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set IMAGE_TAG
id: set_image_tag
run: |
echo "::set-output name=IMAGE_TAG::$(printf $GITHUB_REF_NAME | tr / -)"

- name: Build, tag, and push image to Amazon ECR
env:
IMAGE_TAG: ${{ steps.set_image_tag.outputs.IMAGE_TAG }}
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: geth
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} \
--build-arg COMMIT=${{ github.sha }} \
--build-arg VERSION=${IMAGE_TAG} \
--build-arg BUILDNUM=1 .
docker image push --all-tags $ECR_REGISTRY/$ECR_REPOSITORY