Merge branch 'nuxt3' #9
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: Build & Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout branch | |
| uses: actions/checkout@v4 | |
| - name: Set up SSH | |
| uses: webfactory/[email protected] | |
| with: | |
| ssh-private-key: ${{ secrets.LIGHTSAIL_SSH_KEY }} | |
| - name: Adding Known Hosts | |
| run: ssh-keyscan -H ${{ secrets.LIGHTSAIL_HOST }} >> ~/.ssh/known_hosts | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Install dependencies and build | |
| run: | | |
| npm install | |
| npm run generate | |
| - name: Copy with rsync | |
| run: rsync -avz --delete ./dist/* ${{ secrets.LIGHTSAIL_USER }}@${{ secrets.LIGHTSAIL_HOST }}:laravelseedergenerator/${{ github.sha }} | |
| - name: Launch | |
| env: | |
| LIGHTSAIL_HOST: ${{ secrets.LIGHTSAIL_HOST }} | |
| LIGHTSAIL_USER: ${{ secrets.LIGHTSAIL_USER }} | |
| GITHUB_SHA: ${{ github.sha }} | |
| WORKDIR: "laravelseedergenerator" | |
| run: | | |
| # Change symlink and delete old version | |
| ssh $LIGHTSAIL_USER@$LIGHTSAIL_HOST "cd ~/$WORKDIR && rm ~/$WORKDIR/current 2> /dev/null && ln -sfn ~/$WORKDIR/$GITHUB_SHA ~/$WORKDIR/current" | |
| # Delete old versions | |
| ssh $LIGHTSAIL_USER@$LIGHTSAIL_HOST "cd ~/$WORKDIR && ls -dt */ | tail -n +3 | xargs rm -rf" | |
| - name: Notify deployment success | |
| run: echo "Deployment to Lightsail successful!" |