-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (80 loc) · 2.97 KB
/
build_nd_deploy_to_AKS.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: "build_nd_deploy_to_AKS"
on:
push:
branches:
- main
permissions:
contents: read
id-token: write
jobs:
# # build:
# name: Build Container Image
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Login to DockerHub
# uses: docker/login-action@v3.0.0
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Extract metadata (tags, labels) for Docker
# id: metadata
# uses: docker/metadata-action@v5
# with:
# images: ${{ secrets.DOCKER_USERNAME }}/flaskblog-app:latest
# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: ${{ secrets.DOCKER_USERNAME }}/flaskblog-app:${{ github.sha }}
# labels: ${{ steps.metadata.outputs.labels }}
deploy:
defaults:
run:
shell: bash
working-directory: ./build_deploy
name: Deploy to AKS with Terraform
runs-on: ubuntu-latest
# needs: build
env:
RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
CONTAINER_NAME: ${{ secrets.STORAGE_CONTAINER_NAME }}
STORAGE_ACCESS_KEY: ${{ secrets.STORAGE_ACCESS_KEY }}
TF_LOG: INFO
TF_INPUT: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.ARM_CLIENT_ID }}
tenant-id: ${{ secrets.ARM_TENANT_ID }}
subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }}
# allow-no-subscriptions: true
# - name: Echo TFVARS
# run: echo "${{ secrets.TFVARS }}" > .env
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
- name: Terraform Init
run: terraform init -backend-config="storage_account_name=$STORAGE_ACCOUNT" -backend-config="container_name=$CONTAINER_NAME" -backend-config="resource_group_name=$RESOURCE_GROUP" -backend-config="access_key=$STORAGE_ACCESS_KEY"
- name: Terraform fmt
id: fmt
run: terraform fmt -check -recursive
continue-on-error: true
- name: Terraform Validate
id: validate
if: success() || failure()
run: terraform validate -no-color
- name: Terraform Plan
id: plan
# run: terraform plan -var 'docker_image=${{ secrets.DOCKER_USERNAME }}/flaskblog-app:${{ github.sha }}' -var "resource_group_name=$RESOURCE_GROUP" -input=false -out=plan.tfplan -no-color
run: terraform plan -no-color -out=plan.tfplan -var="docker_image=jojodocker10/flaskblog-app:latest" -input=false -var "resource_group_name=$RESOURCE_GROUP"
# - name: Terraform Apply
# run: terraform apply -auto-approve