Update deploy stage #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Serverless Deployment | |
env: | |
SLACK_WEBHOOK: https://hooks.slack.com/services/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 | |
SLACK_CHANNEL: tangential-ci-updates | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: [published] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: tangential | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '19' | |
- name: Install dependencies | |
run: yarn install | |
env: | |
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }} | |
- name: Run tests | |
run: yarn unit-test | |
id: unit-tests | |
env: | |
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }} | |
- name: Deploy to dev | |
if: github.ref == 'refs/heads/main' | |
run: ./node_modules/serverless/bin/serverless.js deploy --stage dev | |
id: deploy-dev | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Deploy to live | |
if: github.event_name == 'release' && github.event.action == 'published' | |
run: ./node_modules/serverless/bin/serverless.js deploy --stage live | |
id: deploy-live | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Slack Notification for Test Failures | |
if: ${{ failure() && steps.unit-tests.outcome == 'failure' }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: danger | |
SLACK_MESSAGE: 'Tangential Backend: Unit tests failed :bomb:' | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
- name: Slack Notification for Dev Deployment Failure | |
if: ${{ failure() && steps.deploy-dev.outcome == 'failure' }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: danger | |
SLACK_MESSAGE: 'Tangential Backend: Deployment to dev failed :fire:' | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
- name: Slack Notification for Live Deployment Failure | |
if: ${{ failure() && steps.deploy-live.outcome == 'failure' }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: danger | |
SLACK_MESSAGE: 'Tangential Backend: Deployment to live failed :fire:' | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
- name: Slack Success Notification | |
if: ${{ success() }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: good | |
SLACK_MESSAGE: 'Tangential Backend: Deployment successful :tada:' | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |