Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
feat: ci prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Firgrep committed Jul 20, 2024
1 parent a1c7154 commit 9dc6a3b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci-cd-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI/CD Production

on:
workflow_dispatch:
release:
types: [created]

# RUNNER_SERVICE_ACCOUNT:

jobs:
build-and-deploy:
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
SERVICE: ${{ secrets.GCP_SERVICE }}
REGION: ${{ secrets.GCP_REGION }}
RUNNER: ${{ secrets.GCP_SERVICE_RUNER_EMAIL }}
TAG: latest
environment: production
runs-on: ubuntu-latest
steps:
# Checkout the repo and make it accessible to workflow
- name: Checkout
uses: actions/checkout@v4

# Authenticate to Google Cloud
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"

# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
id: docker-auth
uses: "docker/login-action@v3"
with:
username: _json_key
password: "${{ secrets.GOOGLE_CREDENTIALS }}"
registry: "${{ env.REGION }}-docker.pkg.dev"

# Build and Push Container to Google Cloud Artifact Registry
# ! Remember to add "" to secrets that contain @, &, or other special characters
- name: Build and Push Container
run: |
docker build --no-cache \
--build-arg NEXT_PUBLIC_GA_ID="${{secrets.NEXT_PUBLIC_GA_ID}}" \
--build-arg DATABASE_URL="${{secrets.DATABASE_URL}}" \
--build-arg GCP_SECONDARY_BUCKET_NAME=${{secrets.GCP_SECONDARY_BUCKET_NAME}} \
-f Dockerfile \
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" ./
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}"
# Deploy to Cloud Run
- name: Deploy to Cloud Run
run: |
gcloud run deploy ${{env.SERVICE}} \
--platform=managed \
--service-account=${{ env.RUNNER }} \
--region=${{ env.REGION }} \
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" \
--min-instances=default \
--max-instances=1
7 changes: 0 additions & 7 deletions src/server/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ const SECONDARY_BUCKET_NAME = env.GCP_SECONDARY_BUCKET_NAME ?? "invalid";
*/
export const primaryBucket = storage.bucket(PRIMARY_BUCKET_NAME);
export const secondaryBucket = storage.bucket(SECONDARY_BUCKET_NAME);

export async function TestBucket() {
const sa = await storage.getProjectId();
console.log(sa);
const a = await storage.getServiceAccount();
console.log(a);
}

0 comments on commit 9dc6a3b

Please sign in to comment.