-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (55 loc) · 1.92 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
name: Deploy to GCS
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.3
- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }} # Use credentials_json instead of service_account_key
- name: Initialize Terraform
working-directory: iac
run: terraform init
- name: Apply Terraform
working-directory: iac
id: terraform
run: |
terraform apply -auto-approve \
-var="region=${{ secrets.GCP_REGION }}" \
-var="bucket_name=${{ secrets.GCP_BUCKET_NAME }}" \
-var="service_account_id=${{ secrets.GCP_SERVICE_ACCOUNT_ID }}" \
-var="billing_account_id=${{ secrets.GCP_BILLING_ACCOUNT_ID }}"
- name: Get project ID from Terraform output
working-directory: iac
id: get_gcp_project_id
run: echo "PROJECT_ID=$(terraform output -raw gcp_project_id)" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Install dependencies
working-directory: travian/frontend
run: npm install
- name: Build project
working-directory: travian/frontend
run: npm run build
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ env.PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }} # Use credentials_json here too
- name: Upload to GCS
run: |
gsutil -m rsync -r travian/frontend/dist gs://peillac.xyz
- name: Make GCS objects public
run: gsutil iam ch allUsers:objectViewer gs://peillac.xyz