Workflow file for this run
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: Build and Deploy Preview / Frontend | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'frontend/**' | ||
jobs: | ||
build-and-deploy-frontend: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: frontend | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
run_install: false | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'pnpm' | ||
- name: Debug frontend directory | ||
run: ls -la | ||
- name: Get pnpm store directory | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- name: Debug pnpm store path | ||
run: echo "pnpm store path is: $STORE_PATH" | ||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
- name: Build | ||
run: pnpm build | ||
- name: Deploy to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.PREVIEW_SERVER_IP }} | ||
username: ${{ secrets.PREVIEW_USER }} | ||
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }} | ||
source: "dist/" | ||
target: "${{ secrets.TARGET_DIR }}" | ||
strip_components: 1 |