-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
79 lines (72 loc) · 2.93 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Run aws-cdk
description: Run aws-cdk commands
author: tj-actions
inputs:
cdk_stack:
description: 'AWS CDK stack name to execute.'
default: '*'
required: false
cdk_version:
description: 'AWS CDK version to install.'
default: 'latest'
required: false
cdk_subcommand:
description: 'AWS CDK subcommand to execute.'
required: true
cdk_extra_args:
description: 'AWS CDK subcommand arguments.'
required: false
working_dir:
description: 'Working directory.'
default: '.'
required: false
runs:
using: 'composite'
steps:
- name: Check stack status
id: check
working-directory: ${{ inputs.working_dir }}
if: inputs.cdk_stack != '*'
run: |
# Original stack name
CDK_STACK="${{ inputs.cdk_stack }}"
# Replace '/' with '-' in the stack name
MODIFIED_STACK_NAME="${CDK_STACK//\//-}"
stack_status=$(aws cloudformation describe-stacks --stack-name "$MODIFIED_STACK_NAME" --query 'Stacks[0].StackStatus' --output text) 2>/dev/null || true
echo "Stack status: $stack_status"
echo "stack_status=$stack_status" >> $GITHUB_OUTPUT
echo "stack_name=$MODIFIED_STACK_NAME" >> $GITHUB_OUTPUT
shell: bash
- name: Wait for stack update-complete
working-directory: ${{ inputs.working_dir }}
if: steps.check.outputs.stack_status == 'UPDATE_IN_PROGRESS'
run: |
echo "Waiting for "${{ steps.check.outputs.stack_name }}" to complete updating..."
aws cloudformation wait stack-update-complete --stack-name "${{ steps.check.outputs.stack_name }}" 2>/dev/null || true
echo "${{ steps.check.outputs.stack_name }} update complete"
shell: bash
- name: Wait for stack create-complete
working-directory: ${{ inputs.working_dir }}
if: steps.check.outputs.stack_status == 'CREATE_IN_PROGRESS'
run: |
echo "Waiting for "${{ steps.check.outputs.stack_name }}" to complete creating..."
aws cloudformation wait stack-create-complete --stack-name "${{ steps.check.outputs.stack_name }}" 2>/dev/null || true
echo "${{ steps.check.outputs.stack_name }} create complete"
shell: bash
- name: Wait for stack delete-complete
working-directory: ${{ inputs.working_dir }}
if: steps.check.outputs.stack_status == 'DELETE_IN_PROGRESS'
run: |
echo "Waiting for "${{ steps.check.outputs.stack_name }}" to complete deleting..."
aws cloudformation wait stack-delete-complete --stack-name "${{ steps.check.outputs.stack_name }}" 2>/dev/null || true
echo "${{ steps.check.outputs.stack_name }} delete complete"
shell: bash
- name: Run aws-cdk
id: aws-cdk
working-directory: ${{ inputs.working_dir }}
run: |
npx -y cdk@${{ inputs.cdk_version }} ${{ inputs.cdk_subcommand }} ${{ inputs.cdk_extra_args }} "${{ inputs.cdk_stack }}"
shell: bash
branding:
icon: upload-cloud
color: white