Skip to content

Commit

Permalink
Status code can be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
youyo committed Dec 8, 2019
1 parent 8e4c5ad commit 7957eb7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ jobs:
- `working_dir` AWS CDK working directory. (default: '.')
- `actions_comment` Whether or not to comment on pull requests. (default: true)

## Outputs

- `status_code` Returned status code.

## ENV

- `AWS_ACCESS_KEY_ID` **Required**
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
actions_comment:
description: 'Whether or not to comment on pull requests.'
default: true
outputs:
status_code:
description: 'Returned status code.'
runs:
using: 'docker'
image: './Dockerfile'
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function runCdk(){
echo "Run cdk ${INPUT_CDK_SUBCOMMAND} ${*} ${INPUT_CDK_STACK}"
output=$(cdk ${INPUT_CDK_SUBCOMMAND} ${*} ${INPUT_CDK_STACK} 2>&1)
exitCode=${?}
echo ::set-output name=status_code::${exitCode}
echo "${output}"

commentStatus="Failed"
Expand Down
29 changes: 29 additions & 0 deletions examples/notify_difference_to_slack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# If Stack has difference, notify to slack

on: [pull_request]

jobs:
aws_cdk:
runs-on: ubuntu-latest
steps:
- name: cdk diff
id: diff
uses: youyo/aws-cdk-github-actions@master
with:
cdk_subcommand: 'diff'
actions_comment: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'ap-northeast-1'

# https://github.com/marketplace/actions/action-slack
- name: notify slack
uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
author_name: GitHubActions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: ${{ steps.diff.outputs.status_code }} == 1

0 comments on commit 7957eb7

Please sign in to comment.