Skip to content

tried again

tried again #9

name: Build and Push to ECR
on:
push:
branches:
- main
- master
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::381492107876:role/IIC2173-2
# aws-region: us-east-1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID0}}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY0}}
aws-region: us-east-1
- name: Get ECR Repository URI
id: ecr-repo
run: |
echo "::set-output name=uri::$(aws ecr-public describe-repositories --repository-name iic2173-api --query 'repositories[0].repositoryUri' --output text)"
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'false'
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.ecr-repo.outputs.uri }}
REGISTRY_ALIAS: v9b5f4l8
REPOSITORY: iic2173-api
IMAGE_TAG: latest
run: |
cd ./api
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG