-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (87 loc) · 2.81 KB
/
deploy.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Deploy Infrastructure
on: workflow_dispatch
jobs:
terraform-plan:
name: Terraform Plan
runs-on: ubuntu-latest
outputs:
exit_code: ${{ steps.terraform_plan.outputs.exit_code }}
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Terraform Plan
id: terraform_plan
run: |
terraform plan -input=false -detailed-exitcode
echo "exit_code=$?" >> $GITHUB_OUTPUT
terraform-apply:
name: Terraform Apply
needs:
- lint
- terraform-plan
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && needs.terraform-plan.outputs.exit_code == 2
environment: terraform
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Terraform Apply
run: terraform apply -auto-approve -input=false
colmena-build:
name: Colmena Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
- name: Install dependencies
run: nix develop --command "echo dependencies installed"
- name: colmena build
run: nix develop --command "colmena build"
colmena-apply:
name: Colmena Apply
needs:
- colmena-build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
environment: production
env:
GIT_CRYPT_SECRET: ${{ secrets.GIT_CRYPT_SECRET }}
steps:
- uses: actions/checkout@v4
with:
path: infrastructure
- uses: actions/checkout@v4
with:
repository: nevarro-space/infrastructure-secrets
token: ${{ secrets.SECRET_REPO_CLONE_TOKEN }}
path: infrastructure-secrets
- uses: nixbuild/nix-quick-install-action@v29
- name: Unlock git crypt
run: |
echo "$GIT_CRYPT_SECRET" | base64 -d > "$HOME/git-crypt-secret"
cd infrastructure-secrets
nix develop --command "git crypt unlock $HOME/git-crypt-secret"
rm $HOME/git-crypt-secret
- name: Install SSH Key
uses: shimataro/[email protected]
with:
key: ${{ secrets.DEPLOY_SSH_KEY }}
known_hosts: ${{ secrets.MINESHSPC_KNOWN_HOSTS }}
- name: Install dependencies
run: |
cd infrastructure
nix develop --command "echo dependencies installed"
- name: colmena apply
run: |
cd infrastructure
nix develop --command "colmena apply"