Skip to content

Commit 7ec29f6

Browse files
committed
2 parents 9fd4c5b + d40cfef commit 7ec29f6

File tree

16 files changed

+44
-86
lines changed

16 files changed

+44
-86
lines changed

.github/workflows/deployment.yaml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ jobs:
1919
deploy:
2020
runs-on: ubuntu-latest
2121
needs: [test]
22-
defaults:
23-
run:
24-
working-directory: ${{ github.ref == 'refs/heads/main' && './terraform/prod' || './terraform/dev' }}
22+
2523
steps:
2624
- uses: actions/checkout@v6
2725
- name: Google Cloud Auth
@@ -32,19 +30,15 @@ jobs:
3230

3331
- uses: hashicorp/setup-terraform@v4
3432

35-
- name: Terraform fmt
36-
id: fmt
37-
run: terraform fmt -check
38-
39-
- name: Terraform Init
40-
id: init
41-
run: terraform init
42-
43-
- name: Terraform Validate
44-
id: validate
45-
run: terraform validate -no-color
46-
4733
- name: Terraform Apply
4834
id: apply
4935
run: |
50-
terraform apply -auto-approve
36+
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
37+
ENV=prod
38+
elif [ "${GITHUB_REF}" = "refs/heads/development" ]; then
39+
ENV=dev
40+
else
41+
echo "Unsupported branch for deployment: ${GITHUB_REF}"
42+
exit 1
43+
fi
44+
make tf_apply ENV="$ENV"

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.PHONY: *
2+
ENV ?= dev
3+
4+
tf_plan:
5+
cd terraform/ && terraform init -reconfigure -backend-config=backend-$(ENV).hcl -upgrade && terraform fmt -check && terraform validate && terraform plan --var="environment=$(ENV)"
6+
7+
tf_apply:
8+
cd terraform/ && terraform init -reconfigure -backend-config=backend-$(ENV).hcl && terraform apply -auto-approve --var="environment=$(ENV)"

src/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ COPY --chown=node:node . .
1414

1515
ENV PORT=8080
1616

17-
CMD ["npx", "functions-framework", "--target=app"]
17+
CMD ["npx", "functions-framework", "--target=app"]

terraform/backend-dev.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bucket = "tfstate-httparchive"
2+
prefix = "tech-report-apis/dev"

terraform/backend-prod.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bucket = "tfstate-httparchive"
2+
prefix = "tech-report-apis/prod"

terraform/dev/main.tf

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)