-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (101 loc) · 3.28 KB
/
deploy_docker_terraspace.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Deploy using Terraspace
on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
AWS_REGION:
required: false
default: "us-east-1"
type: string
RUBY_VERSION:
required: true
type: string
DOCKER_IMAGE_TAG:
required: true
type: string
APP_NAME:
required: false
type: string
secrets:
OPS_AWS_ACCESS_KEY_ID:
required: true
OPS_AWS_SECRET_ACCESS_KEY:
required: true
AWS_ACCOUNT_ID:
required: true
GH_WORKFLOW_TOKEN:
required: true
TE_DD_API_KEY:
required: false
jobs:
check_org:
name: Check calling organization
runs-on: ubuntu-latest
steps:
- name: Check the calling organization
if: ${{ github.repository_owner != 'trafilea' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('This reusable workflow can only be used by Trafilea.')
deploy:
needs: check_org
name: deploy
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OPS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OPS_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ inputs.AWS_REGION}}
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- run: |
git config --local --remove-section http."https://github.com/"
git config --global url."https://foo:${{ secrets.GH_WORKFLOW_TOKEN }}@github.com/trafilea".insteadOf "https://github.com/trafilea"
- name: Setup Environment Varaibles
id: setup-environment
run: |
echo "TS_ENV=${{ inputs.ENVIRONMENT }}" >> $GITHUB_ENV
echo "AWS_ACCOUNT_ID=${{ secrets.AWS_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "TF_VAR_docker_image_tag=${{ inputs.DOCKER_IMAGE_TAG }}" >> $GITHUB_ENV
echo "TF_VAR_datadog_api_key=${{ secrets.TE_DD_API_KEY }}" >> $GITHUB_ENV
echo "APP_NAME=${{ inputs.APP_NAME }}" >> $GITHUB_ENV
- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: false
terraform_version: 1.1.9
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.OPS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.OPS_AWS_SECRET_ACCESS_KEY }}
aws-region: "${{ inputs.AWS_REGION }}"
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.RUBY_VERSION }}
- name: Install gems (terraspace, rspec-terraspace and terraspace_plugin_aws)
run: bundle install
working-directory: ./terraform
- name: Terraspace Bundle install
run: terraspace bundle
working-directory: ./terraform
- name: Terraspace Init
working-directory: ./terraform
run: |
terraspace all init
- name: Terraspace All Up
working-directory: ./terraform
run: |
terraspace all up -y
- name: Upload Artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: up-logs
path: ./terraform/log/*