Skip to content

Commit e1fd1a4

Browse files
committed
CCM-11029: configure install from github packages
1 parent 3849dc2 commit e1fd1a4

File tree

13 files changed

+60
-29
lines changed

13 files changed

+60
-29
lines changed

.github/actions/acceptance-tests/action.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ runs:
2929
name: terraform-output-${{ inputs.targetComponent }}
3030
- name: "Repo setup"
3131
shell: bash
32-
run: |
33-
npm ci
32+
run: make dependencies
3433

3534
- name: Generate outputs file
3635
shell: bash

.github/workflows/pr_closed.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ jobs:
104104
needs: check-event-schemas-version-change
105105
if: needs.check-event-schemas-version-change.outputs.version_changed == 'true'
106106
runs-on: ubuntu-latest
107+
permissions:
108+
contents: read
109+
packages: read
107110
steps:
108111
- name: "Checkout code"
109112
uses: actions/[email protected]
110113
- name: "Install dependencies"
111-
run: npm ci
114+
run: make dependencies
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112117
- name: "Run provider contract tests"
113118
run: make test-contract-producer
114119

@@ -134,7 +139,9 @@ jobs:
134139
registry-url: 'https://npm.pkg.github.com'
135140

136141
- name: Install dependencies
137-
run: npm ci
142+
run: make dependencies
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138145

139146
- name: Publish to GitHub Packages
140147
run: npm publish --workspace packages/event-schemas

.github/workflows/stage-1-commit.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,15 @@ jobs:
244244
runs-on: ubuntu-latest
245245
permissions:
246246
contents: read
247+
packages: read
247248
steps:
248249
- name: "Checkout code"
249250
uses: actions/checkout@v4
250251

251252
- name: Install dependencies
252-
run: npm ci
253+
run: make dependencies
254+
env:
255+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
253256

254257
- name: Re-generate schemas
255258
run: npm --workspace packages/event-schemas run generate-json-schemas

.github/workflows/stage-2-test.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ env:
3939
permissions:
4040
id-token: write # This is required for requesting the JWT
4141
contents: read # This is required for actions/checkout
42+
packages: read # This is required to install packages from GitHub package registry
4243

4344
jobs:
4445
check-generated-dependencies:
@@ -49,8 +50,9 @@ jobs:
4950
- name: "Checkout code"
5051
uses: actions/[email protected]
5152
- name: "Repo setup"
52-
run: |
53-
npm ci
53+
run: make dependencies
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5456
- name: "Generate dependencies"
5557
run: |
5658
npm run generate-dependencies --workspaces --if-present
@@ -63,8 +65,9 @@ jobs:
6365
- name: "Checkout code"
6466
uses: actions/[email protected]
6567
- name: "Repo setup"
66-
run: |
67-
npm ci
68+
run: make dependencies
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6871
- name: "Generate dependencies"
6972
run: |
7073
npm run generate-dependencies --workspaces --if-present
@@ -92,8 +95,9 @@ jobs:
9295
- name: "Checkout code"
9396
uses: actions/[email protected]
9497
- name: "Repo setup"
95-
run: |
96-
npm ci
98+
run: make dependencies
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97101
- name: "Generate dependencies"
98102
run: |
99103
npm run generate-dependencies --workspaces --if-present
@@ -108,8 +112,9 @@ jobs:
108112
- name: "Checkout code"
109113
uses: actions/[email protected]
110114
- name: "Repo setup"
111-
run: |
112-
npm ci
115+
run: make dependencies
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113118
- name: "Generate dependencies"
114119
run: |
115120
npm run generate-dependencies --workspaces --if-present
@@ -137,7 +142,9 @@ jobs:
137142
- name: "Checkout code"
138143
uses: actions/[email protected]
139144
- name: "Install dependencies"
140-
run: npm ci
145+
run: make dependencies
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141148
- name: "Run provider contract tests"
142149
run: make test-contract-producer
143150
perform-static-analysis:

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ include scripts/init.mk
88
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
99

1010
dependencies: # Install dependencies needed to build and test the project @Pipeline
11-
# TODO: Implement installation of your project dependencies
11+
./scripts/set_github_token.sh
12+
npm ci
1213

1314
build: # Build the project artefact @Pipeline
1415
# TODO: Implement the artefact build step

amplify.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ applications:
88
- cd ..
99
- nvm install 20.13.1
1010
- nvm use 20.13.1
11+
- export GITHUB_TOKEN=$(aws ssm get-parameter --name "$GITHUB_PAT_SSM_PARAM_NAME" --with-decryption --query Parameter.Value --output text)
12+
- ./scripts/set_github_token.sh
1113
- npm ci --cache .npm --prefer-offline
1214
- npm run create-amplify-outputs env
1315
- npm run build

infrastructure/terraform/components/app/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
| Name | Description | Type | Default | Required |
1414
|------|-------------|------|---------|:--------:|
15-
| <a name="input_AMPLIFY_BASIC_AUTH_SECRET"></a> [AMPLIFY\_BASIC\_AUTH\_SECRET](#input\_AMPLIFY\_BASIC\_AUTH\_SECRET) | Secret key/password to use for Amplify Basic Auth - This is entended to be read from CI variables and not commited to any codebase | `string` | `"unset"` | no |
16-
| <a name="input_CSRF_SECRET"></a> [CSRF\_SECRET](#input\_CSRF\_SECRET) | Secure cryptographic key to be used for generating CSRF tokens - This is entended to be read from CI variables and not commited to any codebase | `string` | n/a | yes |
15+
| <a name="input_AMPLIFY_BASIC_AUTH_SECRET"></a> [AMPLIFY\_BASIC\_AUTH\_SECRET](#input\_AMPLIFY\_BASIC\_AUTH\_SECRET) | Secret key/password to use for Amplify Basic Auth - This is intended to be read from CI variables and not committed to any codebase | `string` | `"unset"` | no |
16+
| <a name="input_CSRF_SECRET"></a> [CSRF\_SECRET](#input\_CSRF\_SECRET) | Secure cryptographic key to be used for generating CSRF tokens - This is intended to be read from CI variables and not committed to any codebase | `string` | n/a | yes |
1717
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS Account ID (numeric) | `string` | n/a | yes |
1818
| <a name="input_aws_principal_org_id"></a> [aws\_principal\_org\_id](#input\_aws\_principal\_org\_id) | The AWS Org ID (numeric) | `string` | n/a | yes |
1919
| <a name="input_backup_report_recipient"></a> [backup\_report\_recipient](#input\_backup\_report\_recipient) | Primary recipient of the Backup reports | `string` | `""` | no |
@@ -26,15 +26,15 @@
2626
| <a name="input_data_plane_bus_arn"></a> [data\_plane\_bus\_arn](#input\_data\_plane\_bus\_arn) | Data plane event bus arn | `string` | n/a | yes |
2727
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
2828
| <a name="input_destination_vault_arn"></a> [destination\_vault\_arn](#input\_destination\_vault\_arn) | ARN of the backup vault in the destination account, if this environment should be backed up | `string` | `null` | no |
29-
| <a name="input_enable_amplify_basic_auth"></a> [enable\_amplify\_basic\_auth](#input\_enable\_amplify\_basic\_auth) | Enable a basic set of credentials in the form of a dynamicly generated username and password for the amplify app branches. Not intended for production use | `bool` | `true` | no |
29+
| <a name="input_enable_amplify_basic_auth"></a> [enable\_amplify\_basic\_auth](#input\_enable\_amplify\_basic\_auth) | Enable a basic set of credentials in the form of a dynamically generated username and password for the amplify app branches. Not intended for production use | `bool` | `true` | no |
3030
| <a name="input_enable_amplify_branch_auto_build"></a> [enable\_amplify\_branch\_auto\_build](#input\_enable\_amplify\_branch\_auto\_build) | Enable automatic building of branches | `bool` | `false` | no |
31-
| <a name="input_enable_cognito_built_in_idp"></a> [enable\_cognito\_built\_in\_idp](#input\_enable\_cognito\_built\_in\_idp) | Enable the use of Cognito as an IDP; CIS2 is prefered | `bool` | `false` | no |
31+
| <a name="input_enable_cognito_built_in_idp"></a> [enable\_cognito\_built\_in\_idp](#input\_enable\_cognito\_built\_in\_idp) | Enable the use of Cognito as an IDP; CIS2 is preferred | `bool` | `false` | no |
3232
| <a name="input_enable_event_caching"></a> [enable\_event\_caching](#input\_enable\_event\_caching) | Enable caching of events to an S3 bucket | `bool` | `true` | no |
3333
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
3434
| <a name="input_event_delivery_logging"></a> [event\_delivery\_logging](#input\_event\_delivery\_logging) | Enable SNS Event Delivery logging | `bool` | `true` | no |
3535
| <a name="input_event_delivery_logging_success_sample_percentage"></a> [event\_delivery\_logging\_success\_sample\_percentage](#input\_event\_delivery\_logging\_success\_sample\_percentage) | Enable caching of events to an S3 bucket | `number` | `0` | no |
3636
| <a name="input_external_email_domain"></a> [external\_email\_domain](#input\_external\_email\_domain) | Externally managed domain used to create an SES identity for sending emails from. Validation DNS records will need to be manually configured in the DNS provider. | `string` | `null` | no |
37-
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
37+
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonymous with account short-name) | `string` | n/a | yes |
3838
| <a name="input_kms_deletion_window"></a> [kms\_deletion\_window](#input\_kms\_deletion\_window) | When a kms key is deleted, how long should it wait in the pending deletion state? | `string` | `"30"` | no |
3939
| <a name="input_letter_suppliers"></a> [letter\_suppliers](#input\_letter\_suppliers) | Letter suppliers enabled in the environment | <pre>map(object({<br/> email_addresses = list(string)<br/> enable_polling = bool<br/> default_supplier = optional(bool)<br/> }))</pre> | `{}` | no |
4040
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |

infrastructure/terraform/components/app/amplify_app.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ resource "aws_amplify_app" "main" {
3232
AMPLIFY_MONOREPO_APP_ROOT = "frontend"
3333
API_BASE_URL = module.backend_api.api_base_url
3434
CSRF_SECRET = aws_ssm_parameter.csrf_secret.value
35+
GITHUB_PAT_SSM_PARAM_NAME = data.aws_ssm_parameter.github_pat_ssm_param_name.name
3536
NEXT_PUBLIC_PROMPT_SECONDS_BEFORE_LOGOUT = 120
3637
NEXT_PUBLIC_TIME_TILL_LOGOUT_SECONDS = 900
3738
NOTIFY_ENVIRONMENT = var.environment

infrastructure/terraform/components/app/iam_role_amplify.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,17 @@ data "aws_iam_policy_document" "amplify" {
6464
"arn:aws:logs:${var.region}:${var.aws_account_id}:*"
6565
]
6666
}
67+
68+
statement {
69+
sid = "SSMReadGitHubPAT"
70+
effect = "Allow"
71+
72+
actions = [
73+
"ssm:GetParameter",
74+
]
75+
76+
resources = [
77+
data.aws_ssm_parameter.github_pat_ssm_param_name.arn
78+
]
79+
}
6780
}

infrastructure/terraform/components/app/pre.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
echo "Running app pre.sh"
22

3-
npm ci
3+
make dependencies
44

55
npm run generate-dependencies --workspaces --if-present
66

0 commit comments

Comments
 (0)