Skip to content

chore: prepare deployment, update README.md, sanitise application of … #4

chore: prepare deployment, update README.md, sanitise application of …

chore: prepare deployment, update README.md, sanitise application of … #4

Workflow file for this run

name: Build and Push Make Payment Service image to ECR
on:
push:
branches:
- main
- chore/build-push
paths:
- 'backend/complex/make-payment/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out the 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
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image to ECR
uses: docker/build-push-action@v2
with:
context: ./backend/complex/make-payment/
file: ./backend/complex/make-payment/MakePayment.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:make-payment-${{ github.sha }}
platforms: linux/arm64
- name: Clone deployment repository
uses: actions/checkout@v3
with:
repository: ${{ secrets.DEPLOYMENT_REPO }}
token: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
path: 'deployment-repo'
- name: Update Kubernetes deployment image
run: |
cd deployment-repo
sed -i 's|image: .*|image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:make-payment-${{ github.sha }}|' ./kubernetes/complex/make-payment/make-payment-deployment.yaml
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "Update image tag to ${{ github.sha }}"
git push