-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (136 loc) · 4.53 KB
/
content.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
# ------------------------------------------------------------------------------
# Deploy if the "deployed" label is added
#
# Build image:
# ghcr.io/dfe-digital/early-years-foundation-recovery:pr-123
#
# Deploy to:
# https://ey-recovery-pr-123.london.cloudapps.digital
#
name: Deploy Content App
on:
pull_request:
# branches:
# - main
types:
- labeled
- synchronize
paths-ignore:
- '**/*.md'
- .docker*
- .env.example
- .gitignore
- .pa11yci
- .tool-versions
- .yardopts
- bin/*
- docker-compose.*
- Dockerfile
- terraform
jobs:
deploy:
if: contains(github.event.pull_request.labels.*.name, 'deployed')
runs-on: ubuntu-latest
environment: content
env:
WORKSPACE: content
REGISTRY: ghcr.io/dfe-digital/early-years-foundation-recovery
PR_NUMBER: pr-${{ github.event.number }}
# @see terraform/workspace-variables/app_config.yml[:content]
DOMAIN: ey-recovery-pr-${{ github.event.number }}.london.cloudapps.digital
GOVUK_WEBSITE_ROOT: ey-recovery-pr-${{ github.event.number }}
steps:
-
name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
-
name: Pin Terraform version
uses: hashicorp/[email protected]
with:
terraform_version: 1.1.7
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1
-
name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker image for dependencies
uses: docker/build-push-action@v4
with:
context: .
build-args: BUILDKIT_INLINE_CACHE=1
cache-from: |
${{ env.REGISTRY }}:deps
push: true
tags: ${{ env.REGISTRY }}:deps
target: deps
-
name: Build and push Docker image
uses: docker/build-push-action@v4
with:
target: app
context: .
push: true
build-args: |
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.event.pull_request.head.sha }}
cache-from: |
${{ env.REGISTRY }}:${{ github.event.pull_request.head.sha }}
${{ env.REGISTRY }}:${{ env.PR_NUMBER }}
${{ env.REGISTRY }}:latest
tags: |
${{ env.REGISTRY }}:${{ github.event.pull_request.head.sha }}
${{ env.REGISTRY }}:${{ env.PR_NUMBER }}
-
name: Deploy Review App
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_paas_cf_user: ${{ secrets.CLOUD_FOUNDRY_USERNAME }}
TF_VAR_paas_cf_password: ${{ secrets.CLOUD_FOUNDRY_PASSWORD }}
TF_VAR_paas_app_docker_image: ${{ env.REGISTRY }}:${{ env.PR_NUMBER }}
TF_VAR_paas_app_hostname: ${{ env.PR_NUMBER }}
TF_VAR_paas_app_env_secrets: ${{ toJson(secrets) }}
TF_VAR_paas_app_envs: ${{ toJson(env) }}
run: |
cd terraform/app
terraform init \
-reconfigure \
-input=false \
-backend-config="bucket=${{ secrets.AWS_BUCKET }}" \
-backend-config="key=${{ env.PR_NUMBER }}/terraform.tfstate"
terraform plan \
-var-file ../workspace-variables/${{ env.WORKSPACE }}.tfvars
terraform apply \
-input=false \
-auto-approve \
-var-file ../workspace-variables/${{ env.WORKSPACE }}.tfvars
-
name: Comment URL to PR
uses: mshick/add-pr-comment@v2
with:
message: https://ey-recovery-${{ env.PR_NUMBER }}.london.cloudapps.digital
repo-token: ${{ secrets.GITHUB_TOKEN }}
# -
# name: Tag release in Sentry.io
# env:
# SENTRY_CLI_VERSION: '2.2.0'
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
# SENTRY_ORG: early-years-foundation-reform
# SENTRY_PROJECT: eyf-recovery
# SENTRY_LOG_LEVEL: debug # info
# run: |
# curl -sL https://sentry.io/get-cli/ | bash
# sentry-cli releases new ${{ env.PR_NUMBER }}
# sentry-cli releases set-commits ${{ env.PR_NUMBER }} --auto
# sentry-cli releases finalize ${{ env.PR_NUMBER }}