Skip to content

Commit

Permalink
Create ci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-dyko authored Sep 25, 2024
1 parent 11fc2f6 commit 68cb49d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and push image to registry

on:
push:
branches:
- main
- testing
- master

env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
REGISTRY: 453225900599.dkr.ecr.us-east-1.amazonaws.com
REPOSITORY: se-quotes-api


jobs:
Build-And-Push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Login using AWS CLI
run: aws ecr get-login-password | docker login --username AWS --password-stdin $REGISTRY

- name: Get branch name and trainer name
run: |
echo "SHORT_REF=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
id: vars

- name: Build and push docker image to Amazon ECR
env:
IMAGE_TAG: ${{ steps.vars.outputs.SHORT_REF }}-${{ github.run_number }}
run: |
docker build -f Dockerfile -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
docker rmi $(docker images -q $REGISTRY/$REPOSITORY:$IMAGE_TAG)
- name: NEW TAG
env:
IMAGE_TAG: ${{ steps.vars.outputs.SHORT_REF }}-${{ github.run_number }}
run: |
echo "TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
id: tag

0 comments on commit 68cb49d

Please sign in to comment.