Skip to content

Commit 7957eb7

Browse files
committed
Status code can be used.
1 parent 8e4c5ad commit 7957eb7

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ jobs:
8383
- `working_dir` AWS CDK working directory. (default: '.')
8484
- `actions_comment` Whether or not to comment on pull requests. (default: true)
8585

86+
## Outputs
87+
88+
- `status_code` Returned status code.
89+
8690
## ENV
8791

8892
- `AWS_ACCESS_KEY_ID` **Required**

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ inputs:
2020
actions_comment:
2121
description: 'Whether or not to comment on pull requests.'
2222
default: true
23+
outputs:
24+
status_code:
25+
description: 'Returned status code.'
2326
runs:
2427
using: 'docker'
2528
image: './Dockerfile'

entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function runCdk(){
4545
echo "Run cdk ${INPUT_CDK_SUBCOMMAND} ${*} ${INPUT_CDK_STACK}"
4646
output=$(cdk ${INPUT_CDK_SUBCOMMAND} ${*} ${INPUT_CDK_STACK} 2>&1)
4747
exitCode=${?}
48+
echo ::set-output name=status_code::${exitCode}
4849
echo "${output}"
4950

5051
commentStatus="Failed"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# If Stack has difference, notify to slack
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
aws_cdk:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: cdk diff
10+
id: diff
11+
uses: youyo/aws-cdk-github-actions@master
12+
with:
13+
cdk_subcommand: 'diff'
14+
actions_comment: true
15+
env:
16+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
17+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
18+
AWS_DEFAULT_REGION: 'ap-northeast-1'
19+
20+
# https://github.com/marketplace/actions/action-slack
21+
- name: notify slack
22+
uses: 8398a7/action-slack@v2
23+
with:
24+
status: ${{ job.status }}
25+
author_name: GitHubActions
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
29+
if: ${{ steps.diff.outputs.status_code }} == 1

0 commit comments

Comments
 (0)