chore: bump version #27
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: backend | |
on: | |
push: | |
paths: | |
- 'apps/backend/**' | |
branches: | |
- '**' | |
pull_request: | |
paths: | |
- 'apps/backend/**' | |
branches: | |
- '**' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.14.2 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Create .env file | |
run: | | |
mkdir -p ./apps/backend | |
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> ./apps/backend/.env | |
echo "DATABASE_PWD=${{ secrets.DATABASE_PWD }}" >> ./apps/backend/.env | |
echo "DATABASE_HOST=${{ secrets.DATABASE_HOST }}" >> ./apps/backend/.env | |
echo "DATABASE_PORT=${{ secrets.DATABASE_PORT }}" >> ./apps/backend/.env | |
echo "DATABASE_COLLECTION=${{ secrets.DATABASE_COLLECTION }}" >> ./apps/backend/.env | |
echo "BANDWAGON_SECRET_KEY=${{ secrets.BANDWAGON_SECRET_KEY }}" >> ./apps/backend/.env | |
echo "BANDWAGON_SERVER_ID=${{ secrets.BANDWAGON_SERVER_ID }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_URL=${{ secrets.KEY_CLOAK_URL }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_REALM=${{ secrets.KEY_CLOAK_REALM }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_CLIENT_ID=${{ secrets.KEY_CLOAK_CLIENT_ID }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_CLIENT_SECRET=${{ secrets.KEY_CLOAK_CLIENT_SECRET }}" >> ./apps/backend/.env | |
echo "NODE_ENV=production" >> ./apps/backend/.env | |
- name: Pre compilation | |
run: pnpm run build --filter backend | |
# テスト成功時はこちらのステップが実行される | |
- name: Slack Notification on Success at Testing Stage | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Test Success | |
SLACK_COLOR: good | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
# テスト失敗時はこちらのステップが実行される | |
- name: Slack Notification on Failure at Testing Stage | |
uses: rtCamp/action-slack-notify@v2 | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Test Failure | |
SLACK_COLOR: danger | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
deployment: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
needs: test | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.14.2 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Create .env file | |
run: | | |
mkdir -p ./apps/backend | |
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> ./apps/backend/.env | |
echo "DATABASE_PWD=${{ secrets.DATABASE_PWD }}" >> ./apps/backend/.env | |
echo "DATABASE_HOST=${{ secrets.DATABASE_HOST }}" >> ./apps/backend/.env | |
echo "DATABASE_PORT=${{ secrets.DATABASE_PORT }}" >> ./apps/backend/.env | |
echo "DATABASE_COLLECTION=${{ secrets.DATABASE_COLLECTION }}" >> ./apps/backend/.env | |
echo "BANDWAGON_SECRET_KEY=${{ secrets.BANDWAGON_SECRET_KEY }}" >> ./apps/backend/.env | |
echo "BANDWAGON_SERVER_ID=${{ secrets.BANDWAGON_SERVER_ID }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_URL=${{ secrets.KEY_CLOAK_URL }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_REALM=${{ secrets.KEY_CLOAK_REALM }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_CLIENT_ID=${{ secrets.KEY_CLOAK_CLIENT_ID }}" >> ./apps/backend/.env | |
echo "KEY_CLOAK_CLIENT_SECRET=${{ secrets.KEY_CLOAK_CLIENT_SECRET }}" >> ./apps/backend/.env | |
echo "NODE_ENV=production" >> ./apps/backend/.env | |
- name: Compilation | |
run: pnpm run build --filter backend | |
- name: Prepare files for deployment | |
run: | | |
mkdir -p dist | |
cp -r apps/backend/dist/* dist/ | |
- name: Copy file via ssh key | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSH_KEY }} | |
source: 'dist/*' | |
target: '/var/www/beg-monorepo/apps/backend' | |
overwrite: true | |
- name: SSH to Server and Run Command | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd /var/www/beg-monorepo/apps/backend | |
/home/${{ secrets.USERNAME }}/.local/share/pnpm/pm2 reload ecosystem.config.js | |
# テスト成功時はこちらのステップが実行される | |
- name: Slack Notification on Success at Deployment Stage | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Deploy Success | |
SLACK_COLOR: good | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' | |
# テスト失敗時はこちらのステップが実行される | |
- name: Slack Notification on Failure at Deployment Stage | |
uses: rtCamp/action-slack-notify@v2 | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOKS }} | |
SLACK_CHANNEL: github-actions | |
SLACK_TITLE: Deploy Failure | |
SLACK_COLOR: danger | |
SLACK_FOOTER: 'Powered by Yancey Inc. and its affiliates.' |