Merge pull request #25 from ClassConnect-org/dev #25
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 Microservice | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set Image Tag | |
| run: echo "IMAGE_TAG=$(date +%Y%m%d-%H%M%S)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: Login to GitHub Container Registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | |
| - name: Build & Push Docker Image | |
| run: | | |
| docker build \ | |
| --build-arg VITE_ADMIN_SERVICE_URL="https://172.233.5.227/administration" \ | |
| --build-arg VITE_NOTIF_SERVICE_URL="https://172.233.5.227/notifications" \ | |
| --build-arg VITE_USERS_SERVICE_URL="https://172.233.5.227/users" \ | |
| --build-arg VITE_AI_SERVICE_URL="https://172.233.5.227/ai" \ | |
| -t ghcr.io/classconnect-org/backoffice-app:${{ env.IMAGE_TAG }} . | |
| docker push ghcr.io/classconnect-org/backoffice-app:${{ env.IMAGE_TAG }} | |
| - name: Set Kubeconfig as Environment Variable | |
| run: | | |
| mkdir -p $HOME/.kube | |
| printf "%s" "${{ secrets.KUBE_CONFIG }}" | base64 --decode > $HOME/.kube/config | |
| export KUBECONFIG=$HOME/.kube/config | |
| chmod 600 $HOME/.kube/config | |
| echo "KUBECONFIG set." | |
| - name: Create Kubernetes Secret for GHCR | |
| run: | | |
| kubectl create secret docker-registry ghcr-secret \ | |
| --docker-server=ghcr.io \ | |
| --docker-username=maxogod \ | |
| --docker-password=${{ secrets.PAT }} \ | |
| --docker-email=maxi18wars@gmail.com \ | |
| --dry-run=client -o yaml | kubectl apply -f - | |
| - name: Deploy with Helm | |
| run: | | |
| helm upgrade --install backoffice-app ./helm-chart \ | |
| --set image.repository=ghcr.io/classconnect-org/backoffice-app \ | |
| --set image.tag=${{ env.IMAGE_TAG }} \ | |
| --set deployment.revision=$(date +%s) |