|
12 | 12 | ECS_CLUSTER_QA: "ocl-qa-demo" # set this to your Amazon ECS cluster name |
13 | 13 | ECS_SERVICE_STAGING: "staging-map" # set this to your Amazon ECS service name |
14 | 14 | ECS_CLUSTER_STAGING_PRODUCTION: "ocl-staging-production" # set this to your Amazon ECS cluster name |
| 15 | + ECS_SERVICE_PRODUCTION: "production-map" # set this to your Amazon ECS service name |
15 | 16 |
|
16 | 17 |
|
17 | 18 | jobs: |
@@ -247,3 +248,56 @@ jobs: |
247 | 248 | task-definition: ${{ steps.task-def.outputs.task-definition }} |
248 | 249 | service: ${{ env.ECS_SERVICE_STAGING }} |
249 | 250 | cluster: ${{ env.ECS_CLUSTER_STAGING_PRODUCTION }} |
| 251 | + deploy-production: |
| 252 | + needs: [deploy-staging] |
| 253 | + name: Deploy to Production |
| 254 | + runs-on: ubuntu-latest |
| 255 | + environment: production |
| 256 | + |
| 257 | + steps: |
| 258 | + - name: Configure AWS credentials |
| 259 | + uses: aws-actions/configure-aws-credentials@v1 |
| 260 | + with: |
| 261 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 262 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 263 | + aws-region: ${{ env.AWS_REGION }} |
| 264 | + - name: Login to Amazon ECR |
| 265 | + id: login-ecr |
| 266 | + uses: aws-actions/amazon-ecr-login@v1 |
| 267 | + - name: Checkout repo |
| 268 | + uses: actions/checkout@v3 |
| 269 | + - name: Get npm version |
| 270 | + id: package-version |
| 271 | + uses: martinbeentjes/npm-get-version-action@v1.3.1 |
| 272 | + - name: Add GITHUB_SHA_SHORT env property with commit short sha |
| 273 | + run: echo "GITHUB_SHA_SHORT=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV |
| 274 | + - name: Push image to Amazon ECR |
| 275 | + id: push-image |
| 276 | + env: |
| 277 | + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
| 278 | + IMAGE_TAG: ${{ steps.package-version.outputs.current-version}}-${{env.GITHUB_SHA_SHORT}} |
| 279 | + run: | |
| 280 | + # Build a docker container and |
| 281 | + # push it to ECR so that it can |
| 282 | + # be deployed to ECS. |
| 283 | + docker pull openconceptlab/oclmap:$IMAGE_TAG |
| 284 | + docker tag openconceptlab/oclmap:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production |
| 285 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:production |
| 286 | + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT |
| 287 | + - name: Download task definition |
| 288 | + run: | |
| 289 | + aws ecs describe-task-definition --task-definition $ECS_SERVICE_PRODUCTION --query taskDefinition > task-definition.json |
| 290 | + - name: Fill in the new image ID in the Amazon ECS task definition |
| 291 | + id: task-def |
| 292 | + uses: aws-actions/amazon-ecs-render-task-definition@v1 |
| 293 | + with: |
| 294 | + task-definition: "task-definition.json" |
| 295 | + container-name: ${{ env.ECS_SERVICE_PRODUCTION }} |
| 296 | + image: ${{ steps.push-image.outputs.image }} |
| 297 | + |
| 298 | + - name: Deploy Amazon ECS task definition |
| 299 | + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 |
| 300 | + with: |
| 301 | + task-definition: ${{ steps.task-def.outputs.task-definition }} |
| 302 | + service: ${{ env.ECS_SERVICE_PRODUCTION }} |
| 303 | + cluster: ${{ env.ECS_CLUSTER_STAGING_PRODUCTION }} |
0 commit comments