Added workflow for image build

This commit is contained in:
Venkataraman 2023-05-15 16:34:51 -04:00
parent 2b2d2f2939
commit e293a20f51

57
.github/workflows/docker-image.yaml vendored Normal file
View file

@ -0,0 +1,57 @@
name: Build and Push Backstage Image
on:
workflow_dispatch:
inputs:
branch:
description: "branch to build"
required: true
default: backstage-image
push:
branches:
- backstage-image
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: cnoe
- name: Install packages
run: NODE_OPTIONS="--max_old_space_size=4096" yarn install
- name: Sanity check
run: NODE_OPTIONS="--max_old_space_size=4096" yarn tsc
- name: Bundle up
run: NODE_OPTIONS="--max_old_space_size=4096" yarn build:all
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
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 the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.REPO_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT