-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (56 loc) · 2.05 KB
/
01-deploy-to-review.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
# Control Plane GitHub Action
name: 01-Deploy-To-Review
on:
pull_request:
types:
- opened
- synchronize
branches:
- main
paths-ignore:
- ".github/workflows/**"
# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI
env:
CPLN_ORG: ${{secrets.CPLN_ORG_DEVELOPMENT}}
CPLN_GVC: ${{secrets.CPLN_GVC}}
CPLN_WORKLOAD: ${{secrets.CPLN_WORKLOAD}}
CPLN_TOKEN: ${{secrets.CPLN_TOKEN_DEVELOPMENT}}
CPLN_IMAGE: ${{secrets.CPLN_IMAGE}}
jobs:
deploy-to-review:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Execute Release Tasks
shell: bash
run: ./release/review/release-tasks.sh
- name: Set Short SHA
run: echo "SHORT_SHA=`echo ${{ github.event.pull_request.head.sha }} | cut -c1-7`" >> $GITHUB_ENV
- name: Install Control Plane CLI and Authenticate
shell: bash
run: |
sudo npm install -g @controlplane/cli
cpln --version
cpln profile update default --token ${CPLN_TOKEN}
# echo "SHA: ${GITHUB_SHA}. Short SHA: ${GITHUB_SHA::7}"
- name: Containerize application and push image
shell: bash
run: |
cpln image docker-login
cpln image build --name ${CPLN_IMAGE}:${SHORT_SHA} --dockerfile ./Dockerfile --push
- name: Normalize Branch Name
run: echo "PREVIEW_NAME=`echo ${GITHUB_HEAD_REF} | tr '/' '-'`" >> $GITHUB_ENV
- name: Substitute Tokens in Control Plane YAML Files
shell: bash
working-directory: ./cpln
run: |
sed -i "s/GVC_NAME/${CPLN_GVC}/" cpln-gvc.yaml
sed -i "s/WORKLOAD_NAME/${PREVIEW_NAME}-review-${CPLN_WORKLOAD}/" cpln-workload.yaml
sed -i "s/IMAGE_NAME_TAG/\/\/image\/${CPLN_IMAGE}:${SHORT_SHA}/" cpln-workload.yaml
- name: Run CPLN Apply
shell: bash
working-directory: ./cpln
run: |
cpln apply -f cpln-gvc.yaml
cpln apply -f cpln-workload.yaml --gvc ${CPLN_GVC}