-
Notifications
You must be signed in to change notification settings - Fork 14
74 lines (59 loc) · 2.77 KB
/
deployment_test.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
name: Deployment test
#Run workflow on successful merge to development
on:
- push
- pull_request
jobs:
test-deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Set branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Set dev environment for test deployment
run: |
echo "DEPLOYMENT_ENV=dev" >> $GITHUB_ENV
- name: Configure AWS credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PARAMS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PARAMS_AWS_SECRET_KEY }}
aws-region: eu-central-1
- name: Set parameters and secrets AWS SSM PM and SM
run: |
set -e
for param in $(aws ssm describe-parameters --query "Parameters[*].Name" | sed -e 's/"//g' -e 's/,//g' -e 's/[][]//g');
do
secret_value=$(aws ssm get-parameter --name $param --with-decryption --output text | awk '{ print $7 }')
echo "::add-mask::$secret_value"
echo "$(echo $param | sed 's/_dev//g' | sed 's/-/_/g' | tr '[:lower:]' '[:upper:]')=$secret_value" >> $GITHUB_ENV;
done;
for secret_name in $(aws secretsmanager list-secrets --query 'SecretList[*].{Name:Name,ARN:ARN}' --output text --filters Key="name",Values="ca-member-port_dev_be" | awk '{print $2}'); do
secret_value=$(aws secretsmanager get-secret-value --secret-id $secret_name --query SecretString --output text)
echo "::add-mask::$secret_value"
echo "$(echo $secret_name | sed 's/_dev//g' | sed 's/-/_/g' | tr '[:lower:]' '[:upper:]' )=$secret_value" >> $GITHUB_ENV;
done
# Run a test deployment on the runner with ansible
- name: Run playbook
uses: dawidd6/action-ansible-playbook@671974ed60e946e11964cb0c26e69caaa4b1f559
with:
# Required, playbook filepath
playbook: play.yml
# Optional, directory where playbooks live
directory: ./ansible
# Optional, literal inventory file contents
inventory: |
[casper-mem-port-backend]
localhost ansible_connection=local
# Optional, additional flags to pass to ansible-playbook
options: |
--limit casper-mem-port-backend
--verbose
--extra-vars "git_version=${{ env.BRANCH_NAME }} deployment_env=local"