Format code #6
This file contains hidden or 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
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
paths: | |
- 'servers/**' | |
name: Deploy Server List | |
jobs: | |
build-servers: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: servers | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Skip job if no changes | |
run: echo "No changes detected in servers directory. Skipping build." | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
package_json_file: docs/package.json | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 24 | |
cache: "pnpm" | |
cache-dependency-path: docs/pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
- name: Setup SSH Agent | |
if: github.ref == 'refs/heads/develop' | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SFTP_KEY }} | |
- name: Add SSH Known Hosts | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SFTP_KNOWN_HOSTS }}" > ~/.ssh/known_hosts | |
- name: Deploy SSR build via rsync | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
rsync -avz --delete ./ ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/var/www/servers.setonix | |
- name: Restart SSR application | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
ssh ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }} << 'EOF' | |
export REMOTE_URLS=${{ secrets.REMOTE_URLS }} | |
pm2 stop setonix-servers || true | |
cd /var/www/servers.setonix | |
PORT=${{ secrets.SERVERS_PORT }} pm2 start dist/server/entry.mjs --name setonix-servers --update-env | |
EOF |