upd #52
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: Deploy | |
on: | |
push: | |
branches: | |
- main # или другая ветка, на которую вы хотите реагировать | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Cache pnpm modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.pnpm-store | |
key: ${{ runner.os }}-pnpm-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-pnpm- | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build Docker images | |
run: | | |
pnpm run docker:build:frontend | |
pnpm run docker:build:backend | |
- name: Deploy to server | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SERVER_USER: ${{ secrets.SERVER_USER }} | |
SERVER_HOST: ${{ secrets.SERVER_HOST }} | |
run: | | |
# Setup SSH | |
echo "$SSH_PRIVATE_KEY" > /tmp/id_rsa | |
chmod 600 /tmp/id_rsa | |
ssh-keyscan -H $SERVER_HOST >> ~/.ssh/known_hosts | |
# Deploy | |
ssh -i /tmp/id_rsa $SERVER_USER@$SERVER_HOST << 'EOF' | |
cd /home/altloc/altloc | |
pnpm run docker:down:prod | |
pnpm run docker:build:frontend | |
pnpm run docker:build:backend | |
pnpm run docker:up:prod | |
EOF |