Fix YAML formatting for deploy workflow #2
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
| name: Deploy Studio UI to AWS Lightsail | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'fluxgate-studio-ui-nextjs/**' | ||
| - '.github/workflows/deploy-studio-ui.yml' | ||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| cache-dependency-path: fluxgate-studio-ui-nextjs/package-lock.json | ||
| - name: Install dependencies | ||
| working-directory: fluxgate-studio-ui-nextjs | ||
| run: npm ci | ||
| - name: Build Next.js (standalone) | ||
| working-directory: fluxgate-studio-ui-nextjs | ||
| env: | ||
| NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} | ||
| run: npm run build | ||
| - name: Stop existing service | ||
| uses: appleboy/ssh-action@v1.0.3 | ||
| with: | ||
| host: ${{ secrets.LIGHTSAIL_HOST }} | ||
| username: ${{ secrets.LIGHTSAIL_USER }} | ||
| key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | ||
| script: | | ||
| sudo systemctl stop fluxgate-studio || true | ||
| rm -rf /opt/fluxgate/studio/.next | ||
| mkdir -p /opt/fluxgate/studio | ||
| - name: Copy build to Lightsail | ||
| uses: appleboy/scp-action@v0.1.7 | ||
| with: | ||
| host: ${{ secrets.LIGHTSAIL_HOST }} | ||
| username: ${{ secrets.LIGHTSAIL_USER }} | ||
| key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | ||
| source: "fluxgate-studio-ui-nextjs/.next/standalone/.,fluxgate-studio-ui-nextjs/.next/static" | ||
| target: "/opt/fluxgate/studio/" | ||
| strip_components: 1 | ||
| - name: Copy static files | ||
| uses: appleboy/ssh-action@v1.0.3 | ||
| with: | ||
| host: ${{ secrets.LIGHTSAIL_HOST }} | ||
| username: ${{ secrets.LIGHTSAIL_USER }} | ||
| key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | ||
| script: | | ||
| mkdir -p /opt/fluxgate/studio/.next/static | ||
| cp -r /opt/fluxgate/studio/.next/static /opt/fluxgate/studio/.next/standalone/.next/static 2>/dev/null || true | ||
| - name: Start service | ||
| uses: appleboy/ssh-action@v1.0.3 | ||
| with: | ||
| host: ${{ secrets.LIGHTSAIL_HOST }} | ||
| username: ${{ secrets.LIGHTSAIL_USER }} | ||
| key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | ||
| script: | | ||
| sudo systemctl start fluxgate-studio | ||
| sleep 10 | ||
| sudo systemctl status fluxgate-studio --no-pager | ||
| curl -f http://localhost:3000 || echo "Health check pending" | ||