Skip to content

fix: improve error handling for webhook test failures #274

fix: improve error handling for webhook test failures

fix: improve error handling for webhook test failures #274

Workflow file for this run

name: 'Build and Deploy'
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build-and-deploy-client:
name: Build and Deploy /client
if: "${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'chore(build/client): trigger build action') }}"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.BUILD_WEBHOOK_URL }}
embed-title: 'Deployment Notification'
embed-description: 'Deployment triggered. Proceeding with build and restart.'
embed-footer-text: 'discord.place'
embed-color: 14194756
if: always() # Run this step regardless of the outcome of previous steps
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.SSH_KNOWN_HOST }}" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
- name: Deploy to Server
env:
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
ssh -T -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" << 'EOF' > /dev/null 2>&1
cd discord.place/client
git pull origin main > /dev/null 2>&1
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use $(nvm current)
pnpm install > /dev/null 2>&1
pnpm build > /dev/null 2>&1
pm2 restart discord.place > /dev/null 2>&1
EOF
- uses: chimpdev/bark-github-action@v1.0.1
with:
device_key: ${{ secrets.BARK_KEY }}
server_url: ${{ secrets.BARK_SERVER_URL }}
title: '${{ github.repository }}'
body: 'Client Build and Deploy triggered and completed. Job is ${{ job.status }}.'
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
icon: 'https://i.ibb.co/7d8rL1c3/Git-Hub-Mark-ea2971cee799.jpg'
if: always() # Run this step regardless of the outcome of previous steps
build-and-deploy-server:
name: Build and Deploy /server
if: "${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'chore(build/server): trigger build action') }}"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.BUILD_WEBHOOK_URL }}
embed-title: 'Deployment Notification'
embed-description: 'Deployment triggered. Proceeding with restart.'
embed-footer-text: 'server.discord.place'
embed-color: 14194756
if: always() # Run this step regardless of the outcome of previous steps
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.SSH_KNOWN_HOST }}" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
- name: Deploy to Server
env:
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
ssh -T -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" << 'EOF' > /dev/null 2>&1
cd discord.place/server
git pull origin main > /dev/null 2>&1
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use $(nvm current)
pnpm install > /dev/null 2>&1
pm2 restart api.discord.place > /dev/null 2>&1
EOF
- uses: chimpdev/bark-github-action@v1.0.1
with:
device_key: ${{ secrets.BARK_KEY }}
server_url: ${{ secrets.BARK_SERVER_URL }}
title: '${{ github.repository }}'
body: 'Server Build and Deploy triggered and completed. Job is ${{ job.status }}.'
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
icon: 'https://i.ibb.co/7d8rL1c3/Git-Hub-Mark-ea2971cee799.jpg'
if: always() # Run this step regardless of the outcome of previous steps
build-and-deploy-docs:
name: Build and Deploy /docs
if: "${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'chore(build/docs): trigger build action') }}"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.BUILD_WEBHOOK_URL }}
embed-title: 'Deployment Notification'
embed-description: 'Deployment triggered. Proceeding with build and restart.'
embed-footer-text: 'docs.discord.place'
embed-color: 14194756
if: always() # Run this step regardless of the outcome of previous steps
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.SSH_KNOWN_HOST }}" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
- name: Deploy to Server
env:
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
ssh -T -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" << 'EOF' > /dev/null 2>&1
cd discord.place/docs
git pull origin main > /dev/null 2>&1
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use $(nvm current)
pnpm install > /dev/null 2>&1
pnpm build > /dev/null 2>&1
pm2 restart docs.discord.place > /dev/null 2>&1
EOF
- uses: chimpdev/bark-github-action@v1.0.1
with:
device_key: ${{ secrets.BARK_KEY }}
server_url: ${{ secrets.BARK_SERVER_URL }}
title: '${{ github.repository }}'
body: 'Docs Build and Deploy triggered and completed. Job is ${{ job.status }}.'
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
icon: 'https://i.ibb.co/7d8rL1c3/Git-Hub-Mark-ea2971cee799.jpg'
if: always() # Run this step regardless of the outcome of previous steps