|
3 | 3 |
|
4 | 4 | name: "CI/CD deploy to TEST" |
5 | 5 |
|
| 6 | +concurrency: |
| 7 | + group: terraform-deploy-${{ github.event.inputs.environment }} |
| 8 | + cancel-in-progress: false |
| 9 | + |
6 | 10 | on: |
7 | 11 | workflow_dispatch: |
8 | 12 | inputs: |
9 | 13 | tag: |
10 | | - description: "Branch/Tag/SHA to deploy to test" |
| 14 | + description: "This is the tag that is going to be deployed" |
11 | 15 | required: true |
12 | | - default: "feauture/te-sd-ELI-452-cicd-improvements" |
13 | | - release_type: |
14 | | - description: "Version bump type (use 'rc' to keep the same base and just increment RC)" |
| 16 | + default: "latest" |
| 17 | + environment: |
| 18 | + description: "Target environment (test only)" |
15 | 19 | required: true |
16 | | - default: "rc" |
| 20 | + default: "test" |
17 | 21 | type: choice |
18 | 22 | options: |
19 | | - - rc |
20 | | - - patch |
21 | | - - minor |
22 | | - - major |
| 23 | + - test |
23 | 24 |
|
24 | 25 | jobs: |
25 | 26 | metadata: |
26 | 27 | name: "Set CI/CD metadata" |
27 | 28 | runs-on: ubuntu-latest |
28 | | - timeout-minutes: 10 |
| 29 | + timeout-minutes: 1 |
29 | 30 | outputs: |
30 | 31 | build_datetime: ${{ steps.variables.outputs.build_datetime }} |
31 | 32 | build_timestamp: ${{ steps.variables.outputs.build_timestamp }} |
@@ -66,38 +67,75 @@ jobs: |
66 | 67 | export TAG="${{ steps.variables.outputs.tag }}" |
67 | 68 | make list-variables |
68 | 69 | deploy: |
69 | | - name: "Deploy to test environment" |
| 70 | + name: "Deploy to an environment" |
70 | 71 | runs-on: ubuntu-latest |
71 | 72 | needs: [metadata] |
72 | | - timeout-minutes: 10080 |
| 73 | + environment: ${{ inputs.environment }} |
| 74 | + timeout-minutes: 30 |
73 | 75 | permissions: |
74 | 76 | id-token: write |
75 | 77 | contents: write |
76 | 78 | steps: |
| 79 | + - name: "Setup Terraform" |
| 80 | + uses: hashicorp/setup-terraform@v3 |
| 81 | + with: |
| 82 | + terraform_version: ${{ needs.metadata.outputs.terraform_version }} |
| 83 | + |
| 84 | + - name: "Set up Python" |
| 85 | + uses: actions/setup-python@v5 |
| 86 | + with: |
| 87 | + python-version: "3.13" |
| 88 | + |
77 | 89 | - name: "Checkout Repository" |
78 | 90 | uses: actions/checkout@v5 |
79 | 91 | with: |
80 | 92 | ref: ${{ github.event.inputs.tag }} |
81 | 93 |
|
82 | | - - name: "Install Poetry" |
| 94 | + - name: "Build lambda artefact" |
83 | 95 | run: | |
84 | | - curl -sSL https://install.python-poetry.org | python3 - |
85 | | - echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 96 | + make dependencies install-python |
| 97 | + make build |
86 | 98 |
|
87 | | - - name: "Set up Python" |
88 | | - uses: actions/setup-python@v5 |
| 99 | + - name: "Upload lambda artefact" |
| 100 | + uses: actions/upload-artifact@v4 |
89 | 101 | with: |
90 | | - python-version: "3.13" |
91 | | - cache: 'poetry' |
| 102 | + name: lambda |
| 103 | + path: dist/lambda.zip |
| 104 | + |
| 105 | + - name: "Download Built Lambdas" |
| 106 | + uses: actions/download-artifact@v5 |
| 107 | + with: |
| 108 | + name: lambda |
| 109 | + path: ./build |
92 | 110 |
|
93 | | - - name: "Install dependencies" |
94 | | - run: poetry install |
| 111 | + - name: "Configure AWS Credentials" |
| 112 | + uses: aws-actions/configure-aws-credentials@v5 |
| 113 | + with: |
| 114 | + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role |
| 115 | + aws-region: eu-west-2 |
95 | 116 |
|
96 | | - - name: "Manage Release" |
| 117 | + - name: "Terraform Apply" |
97 | 118 | env: |
98 | | - ENVIRONMENT: 'preprod' |
99 | | - REF: ${{ needs.metadata.outputs.tag }} |
100 | | - INPUT_RELEASE_TYPE: ${{ inputs.release_type }} |
101 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
102 | | - GITHUB_REPOSITORY: ${{ github.repository }} |
103 | | - run: poetry run python scripts/seed_users/tag_and_release.py |
| 119 | + ENVIRONMENT: ${{ inputs.environment }} |
| 120 | + WORKSPACE: "default" |
| 121 | + TF_VAR_API_CA_CERT: ${{ secrets.API_CA_CERT }} |
| 122 | + TF_VAR_API_CLIENT_CERT: ${{ secrets.API_CLIENT_CERT }} |
| 123 | + TF_VAR_API_PRIVATE_KEY_CERT: ${{ secrets.API_PRIVATE_KEY_CERT }} |
| 124 | + TF_VAR_SPLUNK_HEC_TOKEN: ${{ secrets.SPLUNK_HEC_TOKEN }} |
| 125 | + TF_VAR_SPLUNK_HEC_ENDPOINT: ${{ secrets.SPLUNK_HEC_ENDPOINT }} |
| 126 | + run: | |
| 127 | + mkdir -p ./build |
| 128 | + echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=networking tf-command=apply" |
| 129 | + make terraform env=$ENVIRONMENT stack=networking tf-command=apply workspace=$WORKSPACE |
| 130 | + echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=api-layer tf-command=apply" |
| 131 | + make terraform env=$ENVIRONMENT stack=api-layer tf-command=apply workspace=$WORKSPACE |
| 132 | + working-directory: ./infrastructure |
| 133 | + |
| 134 | + regression-tests: |
| 135 | + name: "Regression Tests" |
| 136 | + needs: deploy |
| 137 | + uses: ./.github/workflows/regression-tests.yml |
| 138 | + with: |
| 139 | + ENVIRONMENT: "test" |
| 140 | + VERSION_NUMBER: "main" |
| 141 | + secrets: inherit |
0 commit comments