-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (74 loc) · 2.93 KB
/
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
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: Deploy to Environment
on:
workflow_dispatch:
inputs:
environment:
description: Environment
required: true
default: dev
ref:
description: Git ref to deploy
required: true
default: main
paas_sso_passcode:
description: paas_sso_passcode
required: true
jobs:
turnstyle:
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: softprops/turnstyle@v1
name: Check workflow concurrency
with:
poll-interval-seconds: 20
same-branch-only: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
name: build docker image and deploy
needs: turnstyle
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
name: Checkout Code
with:
ref: ${{ github.event.inputs.ref }}
- name: Pin Terraform version
uses: hashicorp/setup-terraform@v1.2.1
with:
terraform_version: 0.14.0
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Set DOCKER_IMAGE Environment Variable
run: echo "DOCKER_IMAGE=ghcr.io/dfe-digital/ghre-eyfs-cms-alpha:${{ github.sha }}" >> $GITHUB_ENV
- name: Build and push docker image to GitHub Container Registry
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.DOCKER_IMAGE }}
build-args: COMMIT_SHA=${{ github.sha }}
- name: Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Deploy to dev
if: ${{ github.event.inputs.environment == 'dev' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_paas_sso_passcode: ${{ github.event.inputs.paas_sso_passcode }}
run: |
echo "ENV:"
echo ${{env}}
export TF_VAR_paas_app_docker_image=${{ env.DOCKER_IMAGE }}
cd terraform/app
terraform init -reconfigure -input=false -backend-config="bucket=${{secrets.AWS_BUCKET}}"
terraform plan -var-file ../workspace-variables/dev.tfvars
terraform apply -input=false -auto-approve -var-file ../workspace-variables/dev.tfvars -var='secret_paas_app_env_values={"RAILS_MASTER_KEY":"${{secrets.RAILS_MASTER_KEY_DEV}}", "AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}", "AWS_SECRET_ACCESS_KEY": "${{secrets.AWS_SECRET_ACCESS_KEY}}", "AWS_REGION": "${{secrets.AWS_REGION}}", "AWS_BUCKET": "${{secrets.AWS_BUCKET}}", "BASIC_AUTH_USER": "${{secrets.BASIC_AUTH_USER}}", "BASIC_AUTH_PASSWORD": "${{secrets.BASIC_AUTH_PASSWORD}}"}'