diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5eb4ebc..1cebded 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: pull_request jobs: build: name: build - runs-on: [self-hosted, parallel] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Docker Build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index eaf91ea..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: dev_deploy -on: - push: - branches: - - dev - -jobs: - deploy: - name: deploy - runs-on: [self-hosted, parallel] - steps: - - uses: actions/checkout@v3 - - name: Docker Login - shell: bash - env: - DOCKER_USERNAME: ${{ secrets.UWPATH_DOCKER_USER }} - DOCKER_PASSWORD: ${{ secrets.UWPATH_DOCKER_PASSWORD }} - run: docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" - - name: Build Image - run: | - docker compose build - docker image ls - - name: Push to Registry - run: | - docker tag $(docker images uwpath_backend --format "{{.ID}}") uwpathdocker/uwpath_backend:int - docker push uwpathdocker/uwpath_backend:int - - name: Clean Env - if: always() - run: | - docker system prune --volumes -af - docker logout - diff --git a/.github/workflows/gcp_deploy.yml b/.github/workflows/gcp_deploy.yml index defb5e0..a64862c 100644 --- a/.github/workflows/gcp_deploy.yml +++ b/.github/workflows/gcp_deploy.yml @@ -13,7 +13,7 @@ jobs: - name: G-Cloud Authenticate env: SERVICE_CREDENTIALS: ${{ secrets.GCP_SERVICE_CREDENTIALS_DEV }} - SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT_DEV}} + SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT_DEV }} PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_DEV }} run: |- echo "$SERVICE_CREDENTIALS" > ./credentials.json @@ -36,5 +36,3 @@ jobs: - name: Clean Env if: always() run: docker system prune --volumes -af - - diff --git a/.github/workflows/gcp_deploy_prod.yml b/.github/workflows/gcp_deploy_prod.yml new file mode 100644 index 0000000..8c5d634 --- /dev/null +++ b/.github/workflows/gcp_deploy_prod.yml @@ -0,0 +1,38 @@ +name: gcp_deploy_backend_prod +on: + push: + branches: + - master + +jobs: + deploy: + name: deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: G-Cloud Authenticate + env: + SERVICE_CREDENTIALS: ${{ secrets.GCP_SERVICE_CREDENTIALS_PROD }} + SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT_PROD }} + PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_PROD }} + run: |- + echo "$SERVICE_CREDENTIALS" > ./credentials.json + gcloud auth activate-service-account "$SERVICE_ACCOUNT" --key-file=./credentials.json --project="$PROJECT_ID" + gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + - name: Docker Build + env: + IMAGE_NAME: ${{ secrets.GCP_IMAGE_NAME_PROD }} + run: docker build -t "$IMAGE_NAME" . + - name: Push to Container Registry + env: + IMAGE_NAME: ${{ secrets.GCP_IMAGE_NAME_PROD }} + run: sudo -u $USER docker push "$IMAGE_NAME" + - name: Deploy to Cloud Run + env: + IMAGE_NAME: ${{ secrets.GCP_IMAGE_NAME_PROD }} + PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_PROD }} + run: gcloud run deploy uwpath-backend-prod --image="$IMAGE_NAME" --project="$PROJECT_ID" --region=us-central1 + + - name: Clean Env + if: always() + run: docker system prune --volumes -af diff --git a/uwpath_backend/prod_settings.py b/uwpath_backend/prod_settings.py index a286052..58ec302 100644 --- a/uwpath_backend/prod_settings.py +++ b/uwpath_backend/prod_settings.py @@ -40,7 +40,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -ALLOWED_HOSTS = ['api.uwpath.com'] +ALLOWED_HOSTS = ['api.uwpath.com', 'uwpath-backend-prod-qtsbtvgvna-uc.a.run.app'] # Application definition @@ -173,4 +173,5 @@ CORS_ORIGIN_WHITELIST = [ 'https://uwpath.com', + 'https://uwpath-frontend-prod-qtsbtvgvna-uc.a.run.app' ] \ No newline at end of file