-
Notifications
You must be signed in to change notification settings - Fork 3
53 lines (46 loc) · 1.71 KB
/
bootstrap.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
name: Bootstrap
on:
workflow_dispatch: {}
jobs:
secrets:
uses: bn-digital/vault/.github/workflows/import-secrets.yml@latest
secrets: inherit
bootstrap:
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: Create project in Harbor
run: |
curl -X 'POST' \
'https://dcr.bndigital.dev/api/v2.0/projects' \
-H 'authorization: Basic ${{ secrets.HARBOR_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"project_name": "${{ github.event.repository.name }}",
"public": false,
"storage_limit": 10737418240
}'
- 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 }}'"