[CI]: Update frontend deployment image tag #35
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: frontend-services-ci | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| paths: | |
| - '.github/workflows/frontend.yaml' | |
| - 'src/frontend/**' | |
| pull_request_target: | |
| branches: [main] | |
| paths: | |
| - '.github/workflows/frontend.yaml' | |
| - 'src/frontend/**' | |
| jobs: | |
| unit-testing: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: | | |
| cd src/frontend | |
| npm install | |
| - name: Run unit tests | |
| run: | | |
| cd src/frontend | |
| npm test -- --coverage --watchAll=false | |
| code-quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: | | |
| cd src/frontend | |
| npm install | |
| - name: Run ESLint (code quality check) | |
| run: | | |
| cd src/frontend | |
| npm run lint -- --max-warnings=0 --quiet | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| needs: [unit-testing, code-quality] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Docker | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to Docker | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: . | |
| file: ./src/frontend/Dockerfile | |
| push: true | |
| tags: neamulkabiremon/frontend:${{ github.sha }} | |
| update-k8s-deployment: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update Kubernetes Deployment | |
| run: | | |
| sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/frontend:${{ github.sha }}|" kubernetes/frontend/deploy.yaml | |
| cat kubernetes/frontend/deploy.yaml | |
| - name: Commit and push updated Kubernetes manifest | |
| run: | | |
| git config --global user.email "neamulkabiremon@gmail.com" | |
| git config --global user.name "neamulkabiremon" | |
| git add kubernetes/frontend/deploy.yaml | |
| git commit -m "[CI]: Update checkout deployment image tag" | |
| git push |