@@ -11,6 +11,9 @@ permissions:
1111jobs :
1212 deploy :
1313 runs-on : ubuntu-latest
14+ env :
15+ ECS_IMAGE_REPOSITORY : compose-runner-ecs
16+ LAMBDA_IMAGE_REPOSITORY : compose-runner-lambda
1417
1518 steps :
1619 - name : Checkout
@@ -35,25 +38,85 @@ jobs:
3538 pip install -r requirements.txt
3639
3740 - name : Install AWS CDK CLI
38- run : npm install -g aws-cdk@2.130 .0 --registry=https://registry.npmjs.org
41+ run : npm install -g aws-cdk@2.1107 .0 --registry=https://registry.npmjs.org
3942
4043 - name : Configure AWS credentials
4144 uses : aws-actions/configure-aws-credentials@v4
4245 with :
4346 role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
4447 aws-region : ${{ secrets.AWS_REGION }}
4548
49+ - name : Deploy image repository stack
50+ working-directory : infra/cdk
51+ run : |
52+ source .venv/bin/activate
53+ cdk deploy \
54+ ComposeRunnerImageRepositoriesStack \
55+ --require-approval never
56+
57+ - name : Verify ComposeRunnerStack does not synthesize CDK Docker assets
58+ working-directory : infra/cdk
59+ env :
60+ VERSION : ${{ github.event.release.tag_name }}
61+ run : |
62+ source .venv/bin/activate
63+ rm -rf /tmp/compose-runner-cdk-verify
64+ cdk synth \
65+ ComposeRunnerStack \
66+ --output /tmp/compose-runner-cdk-verify \
67+ -c composeRunnerVersion=${VERSION} >/dev/null
68+ jq -e '(.dockerImages // {}) | length == 0' \
69+ /tmp/compose-runner-cdk-verify/ComposeRunnerStack.assets.json >/dev/null || {
70+ echo "ComposeRunnerStack synthesized Docker image assets; deployment would require the CDK bootstrap ECR repository."
71+ cat /tmp/compose-runner-cdk-verify/ComposeRunnerStack.assets.json
72+ exit 1
73+ }
74+
75+ - name : Log in to Amazon ECR
76+ run : |
77+ AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
78+ ECR_REGISTRY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
79+ echo "ECR_REGISTRY=${ECR_REGISTRY}" >> "$GITHUB_ENV"
80+ aws ecr get-login-password | docker login --username AWS --password-stdin "$ECR_REGISTRY"
81+
82+ - name : Build and push release images
83+ env :
84+ VERSION : ${{ github.event.release.tag_name }}
85+ run : |
86+ if [ -z "$VERSION" ]; then
87+ echo "Release tag name is required to publish ECR images"
88+ exit 1
89+ fi
90+
91+ ECS_IMAGE_URI="${ECR_REGISTRY}/${ECS_IMAGE_REPOSITORY}:${VERSION}"
92+ LAMBDA_IMAGE_URI="${ECR_REGISTRY}/${LAMBDA_IMAGE_REPOSITORY}:${VERSION}"
93+
94+ docker build \
95+ --file Dockerfile \
96+ --build-arg COMPOSE_RUNNER_VERSION="${VERSION}" \
97+ --tag "${ECS_IMAGE_URI}" \
98+ .
99+ docker push "${ECS_IMAGE_URI}"
100+
101+ docker build \
102+ --file aws_lambda/Dockerfile \
103+ --build-arg COMPOSE_RUNNER_VERSION="${VERSION}" \
104+ --tag "${LAMBDA_IMAGE_URI}" \
105+ .
106+ docker push "${LAMBDA_IMAGE_URI}"
107+
46108 - name : Deploy CDK stack
47109 working-directory : infra/cdk
48110 env :
49111 RESULTS_PREFIX : compose-runner/results
50112 TASK_CPU : 4096
51113 TASK_MEMORY_MIB : 30720
52114 STATE_MACHINE_TIMEOUT_SECONDS : 7200
115+ VERSION : ${{ github.event.release.tag_name }}
53116 run : |
54117 source .venv/bin/activate
55- VERSION=${GITHUB_REF_NAME}
56118 cdk deploy \
119+ ComposeRunnerStack \
57120 --require-approval never \
58121 --outputs-file cdk-outputs.json \
59122 -c composeRunnerVersion=${VERSION} \
@@ -112,3 +175,17 @@ jobs:
112175 echo "Status response missing status: $status_json"
113176 exit 1
114177 fi
178+
179+ - name : Garbage collect unused CDK bootstrap S3 assets
180+ working-directory : infra/cdk
181+ run : |
182+ source .venv/bin/activate
183+ AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
184+ cdk gc \
185+ "aws://${AWS_ACCOUNT_ID}/${AWS_REGION}" \
186+ --unstable=gc \
187+ --type=s3 \
188+ --action=full \
189+ --created-buffer-days=7 \
190+ --rollback-buffer-days=30 \
191+ --confirm false
0 commit comments