Skip to content

Commit

Permalink
Add build-image.yml deployment workflow for the docker image
Browse files Browse the repository at this point in the history
This is almost the same deployment workflow we use in data-pipelines
repository to build, tag and push the image to ECR:
https://github.com/iFixit/data-pipelines/blob/main/.github/workflows/build-image.yml

Saved the `role-to-assume` value in repository variables in the repo.
  • Loading branch information
batbattur committed Dec 5, 2023
1 parent 5a23f65 commit c58a9d6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build Vigilo image and push to ECR
on:
push:
branches:
- main
# Allow running this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build_image:
name: Build Vigilo image and push to ECR
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

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

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.DEPLOY_IAM_ROLE }}
aws-region: us-east-1

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

- name: Build, Tag, and Push Image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: vigilo
DOCKER_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$DOCKER_TAG -f Dockerfile .
docker tag $REGISTRY/$REPOSITORY:$DOCKER_TAG $REGISTRY/$REPOSITORY:latest
docker push $REGISTRY/$REPOSITORY:$DOCKER_TAG
docker push $REGISTRY/$REPOSITORY:latest

0 comments on commit c58a9d6

Please sign in to comment.