diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..d8a4484 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,29 @@ +name: Deploy to production +on: + push: + branches: [ "main" ] + +jobs: + build: + name: Build image + runs-on: ubuntu-latest + steps: + - name: Checkout repo # This step is necessary, so the environment in which the actions are executed has access to the codebase from repository + uses: actions/checkout@v3 # It takes a code for a branch for which it was trigerred, so when trigerred for a pull request, it will used its code + - name: Configure AWS credentials # TODO update it to use role-to-assume as adviced by the AWS instead of aws-access-key-id and aws-secret-access-key + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-north-1 + - name: Login to Amazon ECR + id: login-ecr # Here we specify id to be able to link to this steps output in the next step + uses: aws-actions/amazon-ecr-login@v1 + - name: Build, tag, and push docker image to Amazon ECR + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: simplebank + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . + docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 97% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index f4ae5b8..d0c2973 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,4 @@ -name: ci-test - +name: Run unit test on: push: branches: [ "main" ]