Skip to content

Commit

Permalink
Added image:tag to build stage to test for ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-sandhu committed Nov 9, 2023
1 parent 2063369 commit a8be652
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/cd-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- dev
- actions-ecr
pull_request:
branches:
- main
Expand All @@ -19,22 +20,19 @@ jobs:
env:
OS: ubuntu-latest
PYTHON: '3.9'

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9

# Install dependencies required for tests
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev -y --no-install-recommends
python -m pip install --upgrade pip
pip install -r ./requirements.txt
# Start running test scripts and generate the coverage report
- name: Generate Coverage Report
env:
Expand Down Expand Up @@ -71,24 +69,20 @@ jobs:
needs: code-test
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

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

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -98,4 +92,5 @@ jobs:
echo "Starting docker build"
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG:${{ github.sha }}

0 comments on commit a8be652

Please sign in to comment.