feat: completely remove testing and mocking #2
Workflow file for this run
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 Realworld React | |
| on: | |
| push: | |
| branches: [release] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/realworld-react:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/realworld-react:${{ github.sha }} | |
| target: builder | |
| - name: Deploy to VPS | |
| env: | |
| VITE_APP_API_URL: ${{ secrets.VITE_APP_API_URL }} | |
| VITE_APP_APP_URL: ${{ secrets.VITE_APP_APP_URL }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no deploy@$VPS_HOST << EOF | |
| # Pull latest image | |
| docker pull $DOCKERHUB_USERNAME/realworld-react:latest | |
| # Extract build artifacts | |
| docker run --rm -v /tmp/react-build:/output \ | |
| $DOCKERHUB_USERNAME/realworld-react:latest \ | |
| sh -c "cp -r /app/dist/* /output/" | |
| # Copy to web directory | |
| sudo rm -rf /var/www/realworld-react/* | |
| sudo cp -r /tmp/react-build/* /var/www/realworld-react/ | |
| sudo chown -R www-data:www-data /var/www/realworld-react | |
| # Cleanup | |
| rm -rf /tmp/react-build | |
| EOF |