Skip to content

Commit

Permalink
Merge pull request #49 from mpiorowski/feat/rewrite-to-postgres
Browse files Browse the repository at this point in the history
feat/rewrite to postgres
  • Loading branch information
mpiorowski authored Aug 10, 2023
2 parents 8951610 + 94b609d commit ca64292
Show file tree
Hide file tree
Showing 168 changed files with 4,920 additions and 7,254 deletions.
180 changes: 90 additions & 90 deletions .github/workflows/deploy-client.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
name: Deploy Client

on:
push:
branches:
- release-client/**
workflow_call:
secrets:
GCP_CREDENTIALS:
required: true
PUBLIC_API_KEY:
required: true
PUBLIC_AUTH_DOMAIN:
required: true
SERVICE_ACCOUNT:
required: true
STRIPE_API_KEY:
required: true
PRIVATE_KEY:
required: true
push:
branches:
- release-client/**
workflow_call:
secrets:
GCP_CREDENTIALS:
required: true
PUBLIC_API_KEY:
required: true
PUBLIC_AUTH_DOMAIN:
required: true
SERVICE_ACCOUNT:
required: true
STRIPE_API_KEY:
required: true
PRIVATE_KEY:
required: true

env:
GAR_LOCATION: europe-north1
PROJECT_ID: rusve-384620
REPOSITORY: rusve-repo
SERVICE: client
REGION: europe-north1
ENV: production
PUBLIC_DOMAIN: https://www.rusve.app
PUBLIC_API_KEY: ${{ secrets.PUBLIC_API_KEY }}
PUBLIC_AUTH_DOMAIN: ${{ secrets.PUBLIC_AUTH_DOMAIN }}
URI_USERS_RUST: users-rust-cdb5ecy4ia-lz.a.run.app
URI_USERS_GO: users-go-cdb5ecy4ia-lz.a.run.app
URI_UTILS_RUST: utils-rust-cdb5ecy4ia-lz.a.run.app
URI_UTILS_GO: utils-go-cdb5ecy4ia-lz.a.run.app
URI_NOTES_RUST: notes-rust-cdb5ecy4ia-lz.a.run.app
URI_NOTES_GO: notes-go-cdb5ecy4ia-lz.a.run.app
URI_DIRECTUS: https://directus-cms.fly.dev
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
GAR_LOCATION: europe-north1
PROJECT_ID: rusve-384620
REPOSITORY: rusve-repo
SERVICE: client
REGION: europe-north1
ENV: production
PUBLIC_DOMAIN: https://www.rusve.app
PUBLIC_API_KEY: ${{ secrets.PUBLIC_API_KEY }}
PUBLIC_AUTH_DOMAIN: ${{ secrets.PUBLIC_AUTH_DOMAIN }}
URI_USERS_RUST: users-rust-cdb5ecy4ia-lz.a.run.app
URI_USERS_GO: users-go-cdb5ecy4ia-lz.a.run.app
URI_UTILS_RUST: utils-rust-cdb5ecy4ia-lz.a.run.app
URI_UTILS_GO: utils-go-cdb5ecy4ia-lz.a.run.app
URI_NOTES_RUST: notes-rust-cdb5ecy4ia-lz.a.run.app
URI_NOTES_GO: notes-go-cdb5ecy4ia-lz.a.run.app
URI_DIRECTUS: https://directus-cms.fly.dev
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}

permissions:
contents: write
id-token: write
checks: write
contents: write
id-token: write
checks: write

jobs:
lint:
uses: ./.github/workflows/lint-client.yml
deploy:
needs:
- lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Docker Auth
id: docker-auth
uses: docker/login-action@v2
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS }}
- name: Create .env.prod file
run: |
touch ./client/.env.prod
echo ENV="$ENV" >> ./client/.env.prod
echo PUBLIC_DOMAIN="$PUBLIC_DOMAIN" >> ./client/.env.prod
echo PUBLIC_API_KEY="$PUBLIC_API_KEY" >> ./client/.env.prod
echo PUBLIC_AUTH_DOMAIN="$PUBLIC_AUTH_DOMAIN" >> ./client/.env.prod
echo URI_USERS_RUST="$URI_USERS_RUST" >> ./client/.env.prod
echo URI_USERS_GO="$URI_USERS_GO" >> ./client/.env.prod
echo URI_UTILS_RUST="$URI_UTILS_RUST" >> ./client/.env.prod
echo URI_UTILS_GO="$URI_UTILS_GO" >> ./client/.env.prod
echo URI_NOTES_RUST="$URI_NOTES_RUST" >> ./client/.env.prod
echo URI_NOTES_GO="$URI_NOTES_GO" >> ./client/.env.prod
echo URI_DIRECTUS="$URI_DIRECTUS" >> ./client/.env.prod
echo STRIPE_API_KEY="$STRIPE_API_KEY" >> ./client/.env.prod
echo SERVICE_ACCOUNT=\'$SERVICE_ACCOUNT\' >> ./client/.env.prod
echo PRIVATE_KEY=\'$PRIVATE_KEY\' >> ./client/.env.prod
- name: Build and Push Container
run: |-
docker build -f ./client/Dockerfile -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./client
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
lint:
uses: ./.github/workflows/lint-client.yml
deploy:
needs:
- lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Docker Auth
id: docker-auth
uses: docker/login-action@v2
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS }}
- name: Create .env.prod file
run: |
touch ./client/.env.prod
echo ENV="$ENV" >> ./client/.env.prod
echo PUBLIC_DOMAIN="$PUBLIC_DOMAIN" >> ./client/.env.prod
echo PUBLIC_API_KEY="$PUBLIC_API_KEY" >> ./client/.env.prod
echo PUBLIC_AUTH_DOMAIN="$PUBLIC_AUTH_DOMAIN" >> ./client/.env.prod
echo URI_USERS_RUST="$URI_USERS_RUST" >> ./client/.env.prod
echo URI_USERS_GO="$URI_USERS_GO" >> ./client/.env.prod
echo URI_UTILS_RUST="$URI_UTILS_RUST" >> ./client/.env.prod
echo URI_UTILS_GO="$URI_UTILS_GO" >> ./client/.env.prod
echo URI_NOTES_RUST="$URI_NOTES_RUST" >> ./client/.env.prod
echo URI_NOTES_GO="$URI_NOTES_GO" >> ./client/.env.prod
echo URI_DIRECTUS="$URI_DIRECTUS" >> ./client/.env.prod
echo STRIPE_API_KEY="$STRIPE_API_KEY" >> ./client/.env.prod
echo SERVICE_ACCOUNT=\'$SERVICE_ACCOUNT\' >> ./client/.env.prod
echo PRIVATE_KEY=\'$PRIVATE_KEY\' >> ./client/.env.prod
- name: Build and Push Container
run: |-
docker build -f ./client/Dockerfile -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./client
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
114 changes: 57 additions & 57 deletions .github/workflows/deploy-notes-go.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
name: Deploy Notes Go

on:
push:
branches:
- release-notes-go/**
workflow_call:
secrets:
GCP_CREDENTIALS:
required: true
DATABASE_URL:
required: true
push:
branches:
- release-notes-go/**
workflow_call:
secrets:
GCP_CREDENTIALS:
required: true
DATABASE_URL:
required: true

env:
GAR_LOCATION: europe-north1
PROJECT_ID: rusve-384620
REPOSITORY: rusve-repo
DATABASE: rusve-db
SERVICE: notes-go
REGION: europe-north1
ENV: production
DATABASE_URL: ${{ secrets.DATABASE_URL }}/notes?tls=true&parseTime=true
# DATABASE_URL=postgresql:///?dbname=${{ env.SERVICE }}&host=/cloudsql/${{ env.PROJECT_ID }}:${{ env.REGION }}:${{ env.DATABASE }}&user=postgres&password=${{ secrets.DB_PASS }}
GAR_LOCATION: europe-north1
PROJECT_ID: rusve-384620
REPOSITORY: rusve-repo
DATABASE: rusve-db
SERVICE: notes-go
REGION: europe-north1
ENV: production
DATABASE_URL: ${{ secrets.DATABASE_URL }}&dbname=notes
# DATABASE_URL=postgresql:///?dbname=${{ env.SERVICE }}&host=/cloudsql/${{ env.PROJECT_ID }}:${{ env.REGION }}:${{ env.DATABASE }}&user=postgres&password=${{ secrets.DB_PASS }}

permissions:
contents: read
id-token: write
contents: read
id-token: write

jobs:
lint:
uses: ./.github/workflows/lint-notes-go.yml
deploy:
needs:
- lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Docker Auth
id: docker-auth
uses: docker/login-action@v2
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS }}
- name: Build and Push Container
run: |-
docker build -f ./service-${{ env.SERVICE }}/Dockerfile -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./service-${{ env.SERVICE }}
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
env_vars: |
ENV=${{ env.ENV }}
DATABASE_URL=${{ env.DATABASE_URL }}
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
lint:
uses: ./.github/workflows/lint-notes-go.yml
deploy:
needs:
- lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Docker Auth
id: docker-auth
uses: docker/login-action@v2
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS }}
- name: Build and Push Container
run: |-
docker build -f ./service-${{ env.SERVICE }}/Dockerfile -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./service-${{ env.SERVICE }}
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
env_vars: |
ENV=${{ env.ENV }}
DATABASE_URL=${{ env.DATABASE_URL }}
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
Loading

0 comments on commit ca64292

Please sign in to comment.