-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENG-5054: Create DB on project startup
- Loading branch information
1 parent
e7819b3
commit 6a01bcf
Showing
1 changed file
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }}'" |