@ossy/deployment-tools 0.0.94 → 0.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 0.0.97 (2026-03-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ossy/deployment-tools
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 0.0.96 (2026-03-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @ossy/deployment-tools
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 0.0.95 (2026-03-28)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @ossy/deployment-tools
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @ossy/deployment-tools
|
|
2
2
|
|
|
3
3
|
Collection of scripts and tools to aid deployment of
|
|
4
|
-
containers and static files to Amazon Web Services through GitHub Actions
|
|
4
|
+
containers and static files to Amazon Web Services through GitHub Actions.
|
|
5
5
|
|
|
6
6
|
## Server
|
|
7
7
|
|
|
@@ -26,22 +26,45 @@ npx @ossy/deployment-tools server status
|
|
|
26
26
|
|
|
27
27
|
## Deployment
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
The first argument after the package name is the **handler** (`deployment`). Commands are **`deployment deploy`** (one site) and **`deployment deploy-all`** (every deployment entry for a platform).
|
|
30
|
+
|
|
31
|
+
Deployments are read from a **glob** of JSON files (e.g. `deployments.json`), and platform definitions from a **platforms** JSON file. Domain and platform for a given site are **not** taken from `ossy.json`; they live in those deployment records (and, in app workflows, mirror **`domain` / `platform` in `src/config.js`** when you use **`@ossy/cli publish`**).
|
|
32
|
+
|
|
33
|
+
### deploy (single domain)
|
|
34
|
+
|
|
31
35
|
```bash
|
|
32
|
-
npx --yes @ossy/deployment-tools deploy \
|
|
33
|
-
--username ${{ github.actor }} \
|
|
34
|
-
--authentication ${{ secrets.GITHUB_TOKEN }} \
|
|
35
|
-
--
|
|
36
|
-
--
|
|
37
|
-
--
|
|
36
|
+
npx --yes @ossy/deployment-tools deployment deploy \
|
|
37
|
+
--username "${{ github.actor }}" \
|
|
38
|
+
--authentication "${{ secrets.GITHUB_TOKEN }}" \
|
|
39
|
+
--domain example.com \
|
|
40
|
+
--platform my-platform \
|
|
41
|
+
--platforms-path packages/infrastructure/bin/deployment-platforms.json \
|
|
42
|
+
--deployments-path "packages/infrastructure/deployments/**/*.json"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Flag | Alias | Description |
|
|
46
|
+
|------|--------|-------------|
|
|
47
|
+
| `--username` | `-u` | User recorded on the deployment request |
|
|
48
|
+
| `--authentication` | `-a` | Token used to authorize the request |
|
|
49
|
+
| `--domain` | `-d` | Target site domain (must match an entry under that platform in the deployments glob) |
|
|
50
|
+
| `--platform` | `-p` | Target deployment platform name |
|
|
51
|
+
| `--platforms-path` | `-pp` | Path to platforms JSON (AWS / queue config) |
|
|
52
|
+
| `--deployments-path` | `-dp` | Glob of deployment JSON files |
|
|
53
|
+
|
|
54
|
+
### deploy-all (whole platform)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx --yes @ossy/deployment-tools deployment deploy-all \
|
|
58
|
+
--username "${{ github.actor }}" \
|
|
59
|
+
--authentication "${{ secrets.GITHUB_TOKEN }}" \
|
|
60
|
+
--platform my-platform \
|
|
61
|
+
--platforms-path packages/infrastructure/bin/deployment-platforms.json \
|
|
62
|
+
--deployments-path "packages/infrastructure/deployments/**/*.json"
|
|
38
63
|
```
|
|
39
64
|
|
|
40
|
-
|
|
65
|
+
### Apps: use @ossy/cli publish
|
|
41
66
|
|
|
42
|
-
|
|
43
|
-
* `cdk diff` compare deployed stack with current state
|
|
44
|
-
* `cdk synth` emits the synthesized CloudFormation template
|
|
67
|
+
For Ossy apps, prefer **`npx @ossy/cli publish`** from the website package: it resolves **`--domain` / `--platform`** from **`src/config.js`** (or **`--config`**) when possible, calls **`deployment deploy`** (or **`deploy-all`** with **`--all`**), then can upload **resource templates** from the same config. See **`packages/cli/README.md`**.
|
|
45
68
|
|
|
46
69
|
## Useful commands
|
|
47
70
|
|
|
@@ -84,7 +107,7 @@ journalctl -u docker.service -n 200 -f
|
|
|
84
107
|
- 1 release new version of the npm package with `npm publish`
|
|
85
108
|
- 2 ssh into the instance with `ssh -i path/to/keys ubuntu@<ip>`
|
|
86
109
|
- 3 stop the deployment-tools services with `sudo systemctl stop deployment-tools.service`
|
|
87
|
-
- 4 remove the old version of the tool
|
|
110
|
+
- 4 remove the old version of the tool with `rm -rf ~/.npm/_npx`
|
|
88
111
|
- 5 start the deployment-tools services again with `sudo systemctl start deployment-tools.service`
|
|
89
112
|
|
|
90
113
|
That's it, the service will download the latest version of the package.
|
|
@@ -103,4 +126,4 @@ sudo apt-get install -y nodejs
|
|
|
103
126
|
# Verify the installation
|
|
104
127
|
node --version
|
|
105
128
|
npm --version
|
|
106
|
-
```
|
|
129
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/deployment-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.97",
|
|
4
4
|
"description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -30,5 +30,6 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"jest": "^27.5.1",
|
|
32
32
|
"jsdoc": "^4.0.2"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "2f021c5267eda824587a8670dc51507ce48720e0"
|
|
34
35
|
}
|
package/src/deploy/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ const deploy = options => {
|
|
|
11
11
|
'-u': '--username',
|
|
12
12
|
|
|
13
13
|
'--authentication': String,
|
|
14
|
-
'
|
|
14
|
+
'-a': '--authentication',
|
|
15
15
|
|
|
16
16
|
'--domain': String,
|
|
17
17
|
'-d': '--domain',
|
|
@@ -46,7 +46,7 @@ const deployAll = options => {
|
|
|
46
46
|
'-u': '--username',
|
|
47
47
|
|
|
48
48
|
'--authentication': String,
|
|
49
|
-
'
|
|
49
|
+
'-a': '--authentication',
|
|
50
50
|
|
|
51
51
|
'--platform': String,
|
|
52
52
|
'-p': '--platform',
|
package/src/index.cli.js
CHANGED
|
File without changes
|
|
@@ -76,7 +76,9 @@ class ContainerDeploymentTarget extends Construct {
|
|
|
76
76
|
|
|
77
77
|
const platformConfigDeployment = new BucketDeployment(this, 'PlatformConfigDeployment', {
|
|
78
78
|
sources: [Source.jsonData('platform-config.json', { ...props.config, awsRoleToAssume: undefined })],
|
|
79
|
-
destinationBucket: props.bucket
|
|
79
|
+
destinationBucket: props.bucket,
|
|
80
|
+
// Default prune:true would delete every other object (e.g. media/*) on each infra deploy.
|
|
81
|
+
prune: false
|
|
80
82
|
})
|
|
81
83
|
|
|
82
84
|
const role = new Role(this, 'role', {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-new */
|
|
2
|
-
const { nanoid } = require('nanoid')
|
|
3
2
|
const { CfnOutput, Stack, RemovalPolicy } = require('aws-cdk-lib')
|
|
3
|
+
const { BackupPlan, BackupVault, BackupResource } = require('aws-cdk-lib/aws-backup')
|
|
4
4
|
const { Bucket, BlockPublicAccess } = require('aws-cdk-lib/aws-s3')
|
|
5
|
-
const { Distribution, PriceClass } = require('aws-cdk-lib/aws-cloudfront')
|
|
6
|
-
const { S3BucketOrigin
|
|
5
|
+
const { Distribution, PriceClass, ResponseHeadersPolicy } = require('aws-cdk-lib/aws-cloudfront')
|
|
6
|
+
const { S3BucketOrigin } = require('aws-cdk-lib/aws-cloudfront-origins')
|
|
7
7
|
const { ContainerDeploymentTarget } = require('./container-deployment-target')
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -17,11 +17,6 @@ class DeploymentTargetStack extends Stack {
|
|
|
17
17
|
throw ('[DeploymentTargetStack] No template provided')
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// create a bucket name before running cdk deploy and put it in config
|
|
21
|
-
// so that it won't change when updating resources
|
|
22
|
-
// const bucketId = nanoid().toLowerCase().replaceAll('_', '').replaceAll('-', '')
|
|
23
|
-
// const bucketName = `${props.config.platformName}-${bucketId}`
|
|
24
|
-
|
|
25
20
|
// TODO: Check if the bucket already exists and use it
|
|
26
21
|
// instead of having the whole deployment fail
|
|
27
22
|
const staticDeploymentTarget =
|
|
@@ -30,6 +25,7 @@ class DeploymentTargetStack extends Stack {
|
|
|
30
25
|
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
|
|
31
26
|
removalPolicy: RemovalPolicy.RETAIN,
|
|
32
27
|
autoDeleteObjects: false,
|
|
28
|
+
versioned: true,
|
|
33
29
|
cors: [{
|
|
34
30
|
allowedHeaders: ['*'],
|
|
35
31
|
allowedMethods: ['GET', 'PUT', 'POST' ],
|
|
@@ -38,9 +34,26 @@ class DeploymentTargetStack extends Stack {
|
|
|
38
34
|
}]
|
|
39
35
|
})
|
|
40
36
|
|
|
37
|
+
const mediaBackupVault = new BackupVault(this, 'StaticMediaBackupVault', {
|
|
38
|
+
backupVaultName: `${props.config.platformName}-static-media`,
|
|
39
|
+
removalPolicy: RemovalPolicy.RETAIN
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const mediaBackupPlan = BackupPlan.daily35DayRetention(this, 'StaticMediaBackupPlan', mediaBackupVault)
|
|
43
|
+
|
|
44
|
+
mediaBackupPlan.addSelection('StaticDeploymentTargetBucket', {
|
|
45
|
+
backupSelectionName: `${props.config.platformName}-s3-static-media`,
|
|
46
|
+
resources: [BackupResource.fromArn(staticDeploymentTarget.bucketArn)],
|
|
47
|
+
allowRestores: true
|
|
48
|
+
})
|
|
49
|
+
|
|
41
50
|
const mediaCDN = new Distribution(this, 'Media', {
|
|
42
51
|
defaultBehavior: {
|
|
43
|
-
origin: S3BucketOrigin.withOriginAccessControl(staticDeploymentTarget, { originPath: '/media' })
|
|
52
|
+
origin: S3BucketOrigin.withOriginAccessControl(staticDeploymentTarget, { originPath: '/media' }),
|
|
53
|
+
// S3 bucket CORS does not add headers on viewer responses; without this, browser fetch()
|
|
54
|
+
// to the CDN is cross-origin and Chrome may block with net::ERR_BLOCKED_BY_ORB.
|
|
55
|
+
responseHeadersPolicy:
|
|
56
|
+
ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT
|
|
44
57
|
},
|
|
45
58
|
priceClass: PriceClass.PRICE_CLASS_100
|
|
46
59
|
})
|