-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (72 loc) · 2.2 KB
/
Copy pathbuild.yml
File metadata and controls
80 lines (72 loc) · 2.2 KB
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
name: CI Build
on:
push:
branches: [ main ]
tags:
- 'v*'
jobs:
build-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker build backend
run: docker build -t clahe-backend ./backend
build-frontend:
runs-on: ubuntu-latest
needs: build-backend
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Optional: log in to a container registry if you want to push images
# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build frontend Docker image
run: docker build -t clahe-frontend ./frontend
# test the build
- name: Run container smoke test
run: |
docker run --rm -p 8080:80 clahe-frontend curl -I http://localhost:8080
# Optional: push to registry for later deployment
# - name: Push image to Docker Hub
# run: docker push clahe-frontend
approve-release:
needs: [build-backend, build-frontend]
runs-on: ubuntu-latest
steps:
- uses: trstringer/manual-approval@v1
with:
approvers: ""
minimum-approvals: 1
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [approve-release]
steps:
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
name: "Release ${{ github.ref_name }}"
body: "Automated release from CI/CD workflow."
infra-plan:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [release]
steps:
- uses: actions/checkout@v4
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.5
- name: Terraform init
working-directory: ./infra
run: terraform init
- name: Terraform validate
working-directory: ./infra
run: terraform validate
- name: Terraform plan
working-directory: ./infra
run: terraform plan -var="version=${{ github.ref_name }}"