-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (70 loc) · 2.42 KB
/
4-plan-service.yml
File metadata and controls
86 lines (70 loc) · 2.42 KB
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
name: 4 - Terraform Plan - Service
on:
workflow_dispatch:
# Run this Service plan after the Infra plan
workflow_run:
workflows: ["1 - Terraform Plan - Infrastructure"]
types:
- completed
defaults:
run:
working-directory: terraform/tf-aws-service
jobs:
tf_service_plan:
name: TF Service Plan
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: develop - Set ENV to staging
if: endsWith(github.ref, '/develop')
run: echo "ENV=staging" >> $GITHUB_ENV
- name: main - Set ENV to prod
if: endsWith(github.ref, '/main')
run: echo "ENV=prod" >> $GITHUB_ENV
- 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: us-west-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.3
- name: Terraform Fmt
id: fmt
run: terraform fmt -check -diff
continue-on-error: true
- name: Terraform Init
id: init
run: make tf-init
continue-on-error: true
- name: Terraform Validate
id: validate
run: terraform validate -no-color
continue-on-error: true
- name: Get App Name & Target Region
run: |
echo "APP_NAME=$(cat ./../environments/common.tfvars.json | jq -r '.app_name')" >> $GITHUB_ENV
echo "REGION=$(cat ./../environments/${{ env.ENV }}/config.tfvars.json | jq -r '.region')" >> $GITHUB_ENV
- name: Copy ECS Task Release Config from S3
run: aws s3 cp s3://${{ env.ENV }}-${{ env.APP_NAME }}-${{ env.REGION }}-configs/last-${{ env.ENV }}-build.tfvars ./
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.3
- name: Terraform Plan
id: plan
run: make tf-plan
continue-on-error: true
- name: Job Results
run: |
echo fmt
test ${{ steps.fmt.outputs.exitcode }} -eq 0
echo init
test ${{ steps.init.outputs.exitcode }} -eq 0
echo validate
test ${{ steps.validate.outputs.exitcode }} -eq 0
echo plan
test ${{ steps.plan.outputs.exitcode }} -eq 0