add package lock json file #3
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: CI/CD frontend-service | |
| on: | |
| push: | |
| paths: | |
| - 'FE-service-v2/**' | |
| pull_request: | |
| paths: | |
| - 'FE-service-v2/**' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout code | |
| - uses: actions/checkout@v4 | |
| # 2. Log in to DockerHub | |
| - name: Log in to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # 3. Build Docker image | |
| - name: Build Docker image | |
| run: | | |
| cd FE-service-v2 | |
| docker build -t ${{ secrets.DOCKER_USERNAME }}/adaptive-learning-frontend:latest . | |
| # 4. Push image to DockerHub | |
| - name: Push Docker image | |
| run: | | |
| docker push ${{ secrets.DOCKER_USERNAME }}/adaptive-learning-frontend:latest | |
| # 5. Deploy to production via SSH | |
| - name: Deploy frontend-service | |
| uses: appleboy/ssh-action@v0.1.8 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| port: ${{ secrets.SERVER_PORT }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cd /opt/adaptive-learning/moodle-adaptive-learning-plugin | |
| docker compose --env-file .env.production -f docker-compose.prod.yml pull frontend-service | |
| docker compose --env-file .env.production -f docker-compose.prod.yml up -d frontend-service |