-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (42 loc) · 1.43 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: "Publish the image to Docker Hub and Deploy to AWS"
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PWD }}
- name: Build and Push Docker Image
run: |
docker-compose -f docker-compose.prod.yml build
docker-compose -f docker-compose.prod.yml push
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1
- name: Setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.0
terraform_working_dir: ./terraform
- name: Terraform init
working_directory: ./terraform
run: terraform init
- name: Terraform plan
working_directory: ./terraform
run: terraform plan
- name: Terraform apply
working_directory: ./terraform
run: terraform apply -auto-approve