Skip to content

Upload image to ECR

Upload image to ECR #9

Workflow file for this run

name: CI/CD Workflow
on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
BUCKET_NAME: abacus-internal-glue-artefacts
jobs:
build-and-test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'dev')) || (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install
- name: Run pre-commit
run: poetry run pre-commit run --all-files
- name: Run tests
run: poetry run pytest tests/
build-docker-image:
needs: build-and-test
runs-on: ubuntu-latest
if: (github.base_ref == 'main' || github.base_ref == 'dev') && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v3
- 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
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: 925061584404.dkr.ecr.eu-north-1.amazonaws.com
ECR_REPOSITORY: rbal
IMAGE_TAG: ${{ github.ref_name }}-${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest