Skip to content

Commit bc98af9

Browse files
committed
First pass for testing
1 parent 4fe4bbe commit bc98af9

File tree

3 files changed

+179
-182
lines changed

3 files changed

+179
-182
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Deploy Backend
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
apigee_environment:
7+
required: true
8+
type: string
9+
environment:
10+
required: true
11+
type: string
12+
sub_environment:
13+
required: true
14+
type: string
15+
workflow_dispatch:
16+
inputs:
17+
apigee_environment:
18+
type: choice
19+
description: Select the Apigee proxy environment
20+
options:
21+
- internal-dev # Add rest later
22+
environment:
23+
type: string
24+
description: Select the backend environment
25+
options:
26+
- dev
27+
- preprod
28+
sub_environment:
29+
type: string
30+
description: Set the sub environment name e.g. pr-xxx, or green/blue in higher environments
31+
32+
jobs:
33+
terraform-plan:
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: ${{ inputs.environment }}
37+
permissions:
38+
id-token: write
39+
contents: read
40+
steps:
41+
- name: Connect to AWS
42+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
43+
with:
44+
aws-region: eu-west-2
45+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
46+
role-session-name: github-actions
47+
48+
- name: Whoami
49+
run: aws sts get-caller-identity
50+
51+
- name: Checkout
52+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
53+
54+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
55+
with:
56+
terraform_version: "1.12.2"
57+
58+
- name: Terraform Init
59+
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
60+
run: make init apigee_environment=${{ inputs.apigee_environment }} environment=${{ inputs.environment }} sub_environment=${{ inputs.sub_environment }}
61+
62+
- name: Terraform Plan
63+
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
64+
run: make plan apigee_environment=${{ inputs.apigee_environment }} environment=${{ inputs.environment }} sub_environment=${{ inputs.sub_environment }}
65+
# TODO - save the plan and use it in the apply step
66+
67+
terraform-apply:
68+
needs: terraform-plan
69+
runs-on: ubuntu-latest
70+
environment:
71+
name: ${{ inputs.environment }}
72+
permissions:
73+
id-token: write
74+
contents: read
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
78+
79+
- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
80+
with:
81+
aws-region: eu-west-2
82+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
83+
role-session-name: github-actions
84+
85+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
86+
with:
87+
terraform_version: "1.12.2"
88+
89+
- name: Terraform Init
90+
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
91+
run: make init apigee_environment=${{ inputs.apigee_environment }} environment=${{ inputs.environment }} sub_environment=${{ inputs.sub_environment }}
92+
93+
- name: Terraform Apply
94+
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
95+
run: make apply apigee_environment=${{ inputs.apigee_environment }} environment=${{ inputs.environment }} sub_environment=${{ inputs.sub_environment }}
96+
# TODO - use a saved plan from the plan step
97+
# TODO - replace with modular e2e test workflow
98+
# e2e-tests:
99+
# if: ${{ vars.RUN_E2E == 'true' && inputs.sub_environment == vars.ACTIVE_ENVIRONMENT }}
100+
# needs: terraform-apply
101+
# runs-on: ubuntu-latest
102+
# permissions:
103+
# id-token: write
104+
# contents: read
105+
# steps:
106+
# - name: Checkout
107+
# uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
108+
109+
# - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
110+
# with:
111+
# aws-region: eu-west-2
112+
# role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
113+
# role-session-name: github-actions
114+
115+
# - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
116+
# with:
117+
# terraform_version: "1.12.2"
118+
119+
# - name: Terraform Init
120+
# working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
121+
# run: make init apigee_environment=${{ inputs.apigee_environment }} environment=${{ inputs.environment }} sub_environment=${{ inputs.sub_environment }}
122+
123+
# - name: Set up Python
124+
# uses: actions/setup-python@v5
125+
# with:
126+
# python-version: "3.11"
127+
128+
# - name: Install Poetry
129+
# run: |
130+
# curl -sSL https://install.python-poetry.org | python3 - --version 2.1.4
131+
# echo "$HOME/.local/bin" >> $GITHUB_PATH
132+
# poetry --version
133+
134+
# - name: Set Poetry to use Python 3.11
135+
# working-directory: ${{ vars.E2E_DIR_PATH }}
136+
# run: |
137+
# poetry env use $(which python3.11)
138+
139+
# - name: Install dependencies with Poetry
140+
# working-directory: ${{ vars.E2E_DIR_PATH }}
141+
# run: |
142+
# poetry install --no-root
143+
144+
# - name: Install oathtool
145+
# run: sudo apt-get update && sudo apt-get install -y oathtool
146+
147+
# - name: Get JWT token for apigee
148+
# env:
149+
# APIGEE_USERNAME: ${{ vars.APIGEE_USERNAME }}
150+
# APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
151+
# APIGEE_OAUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
152+
# APIGEE_OTP_SECRET: ${{ secrets.APIGEE_OTP_KEY }}
153+
# run: |
154+
# CODE=$(oathtool --totp -b "$APIGEE_OTP_SECRET")
155+
# echo "::add-mask::$CODE"
156+
# echo "Requesting access token from Apigee..."
157+
# response=$(curl -s -X POST "https://login.apigee.com/oauth/token" \
158+
# -H "Content-Type: application/x-www-form-urlencoded" \
159+
# -H "Accept: application/json;charset=utf-8" \
160+
# -H "Authorization: Basic $APIGEE_BASIC_AUTH_TOKEN" \
161+
# -d "username=$APIGEE_USERNAME&password=$APIGEE_PASSWORD&mfa_token=$CODE&grant_type=password")
162+
# token=$(echo "$response" | jq -e -r '.access_token')
163+
# if [[ -z "$token" ]]; then
164+
# echo "Failed to retrieve access token"
165+
# exit 1
166+
# fi
167+
# echo "::add-mask::$token"
168+
# echo "APIGEE_ACCESS_TOKEN=$token" >> $GITHUB_ENV
169+
170+
# - name: Run e2e tests
171+
# working-directory: ${{ vars.E2E_DIR_PATH }}
172+
# env:
173+
# APIGEE_ACCESS_TOKEN: ${{ env.APIGEE_ACCESS_TOKEN }}
174+
# APIGEE_USERNAME: [email protected]
175+
# run: |
176+
# export APIGEE_ENVIRONMENT=internal-dev
177+
# export PROXY_NAME=immunisation-fhir-api-${{ inputs.sub_environment }}
178+
# export SERVICE_BASE_PATH=immunisation-fhir-api/FHIR/R4-${{ inputs.sub_environment }}
179+
# make run-immunization

.github/workflows/deploy-blue-green.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/deploy-template.yml

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)