Merge branch 'develop' of https://github.com/ClickMeee/client into de… #79
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 Vite Project to Nginx Server | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout the code from GitHub | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| # 2. Set the VITE_API_URL environment variable | |
| - name: Create .env file | |
| run: | | |
| echo ${{ secrets.HOST_NAME }} > .env | |
| cat .env | |
| # 2. Set up Node.js 22 | |
| - name: Set up Node.js 22 | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '22' | |
| # 3. Install dependencies | |
| - name: Install dependencies | |
| run: npm install | |
| # 4. Build the project with Vite | |
| - name: Build with Vite | |
| run: npx vite build | |
| # 5. SCP the build files to the remote server | |
| - name: SCP build files to remote server | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.AWS_HOST }} | |
| username: changuii | |
| password: ${{ secrets.AWS_PASSWORD }} | |
| port: ${{ secrets.AWS_PORT }} | |
| source: "./dist/*" | |
| target: ${{ secrets.TARGET_DIRECTORY }} | |
| # 6. Deploy the build folder to the remote server | |
| - name: Deploy to server via SSH | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.AWS_HOST }} | |
| username: changuii | |
| password: ${{ secrets.AWS_PASSWORD }} | |
| port: ${{ secrets.AWS_PORT }} | |
| script: | | |
| # Delete old files in the web server folder | |
| sudo rm -rf ./clickmeee/web/files/dist | |
| sudo mv ./clickmeee/deploy_data/dist ./clickmeee/web/files | |
| sudo rm -rf ./clickmeee/deploy_data/dist |