replaced aws cli #110
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: [ "eks" ] | |
jobs: | |
build-api: | |
name: Build API Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure AWS ECR credentials | |
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: ${{secrets.AWS_REGION}} | |
- name: Login to Amazon ECR | |
id: login-aws-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push API image to ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-aws-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{secrets.API_IMAGE_REPO}} | |
IMAGE_TAG: v2 | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./api | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
build-frontend: | |
name: Build Frontend Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure AWS ECR credentials | |
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: ${{secrets.AWS_REGION}} | |
- name: Login to Amazon ECR | |
id: login-aws-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push Frontened image to ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-aws-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{secrets.FRONTEND_IMAGE_REPO}} | |
IMAGE_TAG: v2 | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./frontend | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
deploy: | |
name: Deploy to EKS | |
runs-on: arc-runner-set | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
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: ${{secrets.AWS_REGION}} | |
- name: Install curl | |
run: | | |
echo "installing curl..." | |
sudo apt-get update | |
sudo apt-get install -y curl | |
- name: Intall Helm | |
run: | | |
echo "installing helm..." | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
- name: Install AWS CLI | |
run: | | |
echo "installing aws cli..." | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
- name: Configure Kubectl | |
run: | | |
echo "configuring kubectl" | |
aws eks update-kubeconfig --name ${{secrets.K8S_CLUSTER_NAME}} --region ${{secrets.AWS_REGION}} | |
- name: Install/Update Helm Chart | |
run: | | |
echo "installing/updating helm chart..." | |
helm upgrade --install todo-app ./todo --set database.host=${{secrets.DB_HOST}} --set database.username=${{secrets.DB_USERNAME}} --set database.password=${{secrets.DB_PASSWORD}} --set api.image.repository=${{secrets.API_IMAGE_URI}} --set frontend.image.repository=${{secrets.FRONTEND_IMAGE_URI}} | |