Merge remote-tracking branch 'origin/github-actions' into github-actions #90
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: Docker Deployment Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - github-actions | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout Code | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Decrypt .env files | |
| run: | | |
| for f in */*/.env.gpg; do | |
| [ -f "$f" ] || continue | |
| out="${f%.gpg}" # remove .gpg extension | |
| echo "Decrypting $f → $out" | |
| gpg --batch --yes --passphrase "${{ secrets.GPG_PASSPHRASE }}" -o "$out" -d "$f" | |
| done | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push all services | |
| run: | | |
| docker compose build | |
| docker compose push | |
| - name: Authenticate to Google Cloud | |
| id: 'auth' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
| - name: Set up Cloud SDK | |
| uses: 'google-github-actions/setup-gcloud@v3' | |
| - name: Remove PORT env variables from the files. | |
| run: | | |
| sed -i '/^PORT=/d' question-service/question-service/.env | |
| sed -i '/^PORT=/d' matching-service/matching-service/.env | |
| sed -i '/^PORT=/d' user-service/user-service/.env | |
| sed -i '/^PORT=/d' collaboration-service/collaboration-service/.env | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy question-service \ | |
| --image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/question-service:latest \ | |
| --region asia-southeast1 \ | |
| --env-vars-file=question-service/question-service/.env \ | |
| --allow-unauthenticated | |
| gcloud run deploy matching-service \ | |
| --image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/matching-service:latest \ | |
| --region asia-southeast1 \ | |
| --env-vars-file=matching-service/matching-service/.env \ | |
| --allow-unauthenticated | |
| gcloud run deploy user-service \ | |
| --image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/user-service:latest \ | |
| --region asia-southeast1 \ | |
| --env-vars-file=user-service/user-service/.env \ | |
| --allow-unauthenticated | |
| gcloud run deploy collaboration-service \ | |
| --image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/collaboration-service:latest \ | |
| --region asia-southeast1 \ | |
| --env-vars-file=collaboration-service/collaboration-service/.env \ | |
| --allow-unauthenticated |