Skip to content

Commit

Permalink
ENG-5054: Create DB on project startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ozhyhin-nikita committed Oct 5, 2023
1 parent e7819b3 commit 6a01bcf
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,38 @@ on:
workflow_dispatch: {}

jobs:
vault:
uses: bn-digital/vault/.github/workflows/sync.yml@latest
secrets: inherit
pulumi:
uses: bn-digital/pulumi/.github/workflows/pulumi-infrastructure.yml@latest
secrets:
uses: bn-digital/vault/.github/workflows/import-secrets.yml@latest
secrets: inherit

database:
needs: [secrets]
runs-on: self-hosted
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Import Vault secrets
uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ENDPOINT }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
infrastructure/data/digitalocean token | DIGITALOCEAN_TOKEN ;
infrastructure/data/kubernetes cluster | KUBERNETES_CLUSTER ;
infrastructure/data/postgresql password | PGPASSWORD;
- name: Setup DigitalOcean cli
uses: digitalocean/action-doctl@v2
with:
token: ${{ env.DIGITALOCEAN_TOKEN }}

- name: Configure Kubernetes context
run: doctl kubernetes cluster kubeconfig save ${{ env.KUBERNETES_CLUSTER }} --set-current-context

- name: Setup kubectl
uses: azure/setup-kubectl@v3

- name: Create DB
env:
DB_NAME: ${{ github.event.repository.name }}
run: kubectl -n staging exec -it postgresql-0 -- /bin/bash -c "export PGPASSWORD='${{ env.PGPASSWORD }}' && createdb -U bn '${{ env.DB_NAME }}'"

0 comments on commit 6a01bcf

Please sign in to comment.