|
@@ -34,7 +34,7 @@ defaults:
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
deploy-playground:
|
|
deploy-playground:
|
|
- name: Create an EC2 instance and configure docker-compose stack
|
|
|
|
|
|
+ name: Deploy Playground Job
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
env:
|
|
STACK_NAME: ${{ github.event.inputs.stackNamePrefix }}-${{ github.event.inputs.branchName }}-${{ github.run_number }}
|
|
STACK_NAME: ${{ github.event.inputs.stackNamePrefix }}-${{ github.event.inputs.branchName }}-${{ github.run_number }}
|
|
@@ -52,6 +52,16 @@ jobs:
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: us-east-1
|
|
aws-region: us-east-1
|
|
|
|
|
|
|
|
+ - name: Check if CloudFormation stack exists
|
|
|
|
+ id: stack_exists
|
|
|
|
+ run: |
|
|
|
|
+ if aws cloudformation describe-stacks --stack-name ${{ env.STACK_NAME }} >/dev/null 2>/dev/null; then
|
|
|
|
+ echo "Stack already exists"
|
|
|
|
+ exit 1
|
|
|
|
+ else
|
|
|
|
+ echo "Stack does not exist"
|
|
|
|
+ fi
|
|
|
|
+
|
|
- name: Deploy to AWS CloudFormation
|
|
- name: Deploy to AWS CloudFormation
|
|
uses: aws-actions/aws-cloudformation-github-deploy@v1
|
|
uses: aws-actions/aws-cloudformation-github-deploy@v1
|
|
id: deploy_stack
|
|
id: deploy_stack
|
|
@@ -74,3 +84,18 @@ jobs:
|
|
options: |
|
|
options: |
|
|
--extra-vars "git_repo=${{ github.event.inputs.gitRepo }} \
|
|
--extra-vars "git_repo=${{ github.event.inputs.gitRepo }} \
|
|
branch_name=${{ github.event.inputs.branchName }}"
|
|
branch_name=${{ github.event.inputs.branchName }}"
|
|
|
|
+
|
|
|
|
+ - name: Save the endpoints file as an artifact
|
|
|
|
+ uses: actions/upload-artifact@v2
|
|
|
|
+ with:
|
|
|
|
+ name: endpoints
|
|
|
|
+ path: devops/aws/endpoints.txt
|
|
|
|
+
|
|
|
|
+ - name: Delete CloudFormation Stack if any step failed
|
|
|
|
+ # Skip if stack already existed
|
|
|
|
+ if: failure() && steps.stack_exists.outcome != 'failed'
|
|
|
|
+ run: |
|
|
|
|
+ echo "Deleting ${{ env.STACK_NAME }} stack"
|
|
|
|
+ aws cloudformation delete-stack --stack-name ${{ env.STACK_NAME }}
|
|
|
|
+ echo "Waiting for ${{ env.STACK_NAME }} to be deleted..."
|
|
|
|
+ aws cloudformation wait stack-delete-complete --stack-name ${{ env.STACK_NAME }}
|