name: Deploy
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
start:
runs-on: ubuntu-latest
steps:
- name: Slack notification start
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_USERNAME: Github Actions
SLACK_ICON_EMOJI: ':octocat:'
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: 'STARTED DEPLOY'
deploy:
runs-on: ubuntu-latest
needs: start
steps:
- name: Deploy
run: |
# デプロイ処理
finish:
if: always()
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
MESSAGE='SUCCESSED DEPLOY'
if [ "${{ needs.deploy.result }}" == "failure" ]; then
MESSAGE='FAILURED DEPLOY <!channel>'
fi
echo "::set-output name=MESSAGE::$MESSAGE"
id: success_or_failure
- name: Slack notification finish on Success
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_USERNAME: Github Actions
SLACK_ICON_EMOJI: ':octocat:'
SLACK_COLOR: ${{ needs.deploy.result }}
SLACK_MESSAGE: ${{ steps.success_or_failure.outputs.MESSAGE }}