-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (71 loc) · 2.17 KB
/
cd.yaml
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
name: CD
on:
workflow_dispatch:
inputs:
image_tag:
description: 'The image tag for deployment'
required: true
type: string
env:
DOCKER_IMAGE: ${{ github.event.inputs.image_tag }}
TF_TOKEN_app_terraform_io: ${{ secrets.TERRAFORM_TOKEN }}
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
DJANGO_KEY: ${{ secrets.DJANGO_KEY }}
DJANGO_HOSTS: ${{ vars.DJANGO_HOSTS }}
DJANGO_CSRF: ${{ vars.DJANGO_CSRF }}
DJANGO_STATIC: ${{ vars.DJANGO_STATIC }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
jobs:
prepare-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Set up CDK for Terraform
run: |
pip install --user pipenv
npm install -g cdktf-cli
- name: cdktf synth
run: |
pipenv install
cdktf synth
working-directory: cdktf
- name: Make Terraform plan
run: |
terraform init
terraform plan -out=tfplan
working-directory: cdktf/cdktf.out/stacks/urlshortener-stack
- name: Show Terraform plan
run: terraform show tfplan
working-directory: cdktf/cdktf.out/stacks/urlshortener-stack
- name: Upload plan as artifact
uses: actions/upload-artifact@v4
with:
name: cdktf
path: cdktf
deploy:
needs: prepare-deploy
runs-on: ubuntu-latest
environment: 'main'
steps:
- name: Download plan artifact
uses: actions/download-artifact@v4
with:
name: cdktf
path: ./
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Deploy
run: |
terraform init
terraform apply tfplan
working-directory: cdktf.out/stacks/urlshortener-stack
- name: Upload static files
run: sh swa.sh ${{ github.event.inputs.image_tag }}