Skip to content

Merge pull request #65 from cheehongw/deployment #2

Merge pull request #65 from cheehongw/deployment

Merge pull request #65 from cheehongw/deployment #2

name: Selectively Build and Push to Artifact Registry
on:
push:
branches: ["master"]
env:
PROJECT_ID: cs3219-400714
REGION: asia-southeast1
GAR_LOCATION: asia-southeast1-docker.pkg.dev/cs3219-400714/peerprep/
jobs:
build-push-artifact:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
- name: Detect Changes in Microservices
id: changes
uses: dorny/paths-filter@v2
with:
filters: |
frontend:
- 'frontend/**'
user_service:
- 'user_service/**'
question_service:
- 'question_service/**'
matching_service:
- 'user_service/**'
match_worker:
- 'match_worker/**'
collab_service:
- 'collab_service/**'
- name: 'Create env file'
run: |
echo "${{ secrets.ENV_FILE }}" > .env
- name: "Set up google auth"
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
- name: "Use gcloud CLI"
run: "gcloud info"
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: 1. Build and Push frontend
if: steps.changes.outputs.frontend == 'true'
run: |
docker-compose build frontend
docker-compose push frontend
- name: 2. Build and Push question-service
if: steps.changes.outputs.question_service == 'true'
run: |
docker-compose build question-service
docker-compose push question-service
- name: 3. Build and Push user-service
if: steps.changes.outputs.user_service == 'true'
run: |
docker-compose build user-service
docker-compose push user-service
- name: 4. Build and Push matching-service
if: steps.changes.outputs.matching_service == 'true'
run: |
docker-compose build matching-service
docker-compose push matching-service
- name: 5. Build and Push match-worker
if: steps.changes.outputs.match_worker == 'true'
run: |
docker-compose build match-worker
docker-compose push match-worker
- name: 6. Build and Push collab-service
if: steps.changes.outputs.collab_service == 'true'
run: |
docker-compose build collab-service
docker-compose push collab-service