Exercise 11.18 Unsuccessful Deployment Test #44
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: Deployment pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize] | |
jobs: | |
build_and_test_app: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Setup Node JS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
- name: Check style | |
run: npm run eslint | |
- name: Build the app | |
run: npm run build | |
- name: Run tests | |
run: npm run test | |
- name: e2e tests | |
uses: cypress-io/github-action@v6 | |
with: | |
start: npm run start-prod | |
wait-on: http://localhost:5000 | |
trigger_deployment: | |
# Trigger deployment only on push on main, and also when #skip is not present in commit message | |
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ', '), '#skip') }} | |
needs: [build_and_test_app] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Trigger deployment | |
run: curl https://api.render.com/deploy/srv-${{ secrets.RENDER_SERVICE_ID }}?key=${{ secrets.RENDER_SECRET_KEY }} | |
- name: Notify about successful deployment | |
uses: rjstone/discord-webhook-notify@v1 | |
if: ${{ success() }} | |
with: | |
severity: info | |
color: "#22BB33" | |
text: A new version of Pokedex deployed by ${{ github.event.head_commit.author.username }} | |
details: to ${{ github.repository }} by ${{ github.event.head_commit.author.username }} | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
- name: Notify about unsuccessful deployment | |
uses: rjstone/discord-webhook-notify@v1 | |
if: ${{ failure() }} | |
with: | |
severity: error | |
text: Build failed | |
color: "#BB2124" | |
details: https://github.com/${{ github.repository }}/commit/${{ github.sha }} by ${{ github.event.head_commit.author.username }} broke the build :( | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
tag_release: | |
needs: [trigger_deployment] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
with: | |
fetch-depth: "0" | |
uses: actions/checkout@v4 | |
- name: Bump version and push tag | |
if: ${{ github.event_name == 'push' }} | |
uses: anothrNick/github-tag-action@1.64.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
#DRY_RUN: true | |
VERBOSE: true | |
DEFAULT_BUMP: patch |