forked from thoughtworks/HeartBeat
-
Notifications
You must be signed in to change notification settings - Fork 15
126 lines (120 loc) · 3.72 KB
/
Release.yaml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Release
on:
push:
tags:
- '*'
env:
REPO_NAME: ${{ github.event.repository.name }}
LOWCASE_REPO_NAME: ${{ github.repository_owner}}/heartbeat
jobs:
build_backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JAVA_VERSION || 19 }}
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/[email protected]
- name: Build
run: ./gradlew clean build
- uses: actions/upload-artifact@v4
with:
name: backend-app
path: backend/build/libs/heartbeat-backend-0.0.1-SNAPSHOT.jar
retention-days: ${{ vars.RETENTION_DAYS || 10 }}
build_frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install
run: |
npm install -g pnpm
pnpm install --no-frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Build
run: |
pnpm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-app
path: frontend/dist
retention-days: ${{ vars.RETENTION_DAYS || 10 }}
build_and_push_image:
runs-on: ubuntu-latest
needs:
- build_frontend
- build_backend
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Tag name
run: |
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV"
- name: Build and Push Docker Image for frontend
uses: docker/build-push-action@v5
with:
file: ./ops/infra/Dockerfile.frontend
push: true
tags: |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:${{ env.TAG_NAME }}
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:latest
- name: Build and Push Docker Image for backend
uses: docker/build-push-action@v5
with:
file: ./ops/infra/Dockerfile.backend
push: true
tags: |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:${{ env.TAG_NAME }}
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:latest
release:
runs-on: ubuntu-latest
needs:
- build_and_push_image
steps:
- uses: actions/checkout@v4
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-app
path: ./${{ env.REPO_NAME }}-frontend
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-app
- name: List
run: |
ls -a
- name: Release
id: build
run: |
mkdir ${{ env.REPO_NAME }}
mv ./${{ env.REPO_NAME }}-frontend ${{ env.REPO_NAME }}
mv heartbeat-backend-0.0.1-SNAPSHOT.jar ${{ env.REPO_NAME }}
zip -r ${{ env.REPO_NAME }}-$(git tag --sort version:refname | tail -n 1).zip ${{ env.REPO_NAME }}
ls
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV"
- name: Upload zip file
uses: softprops/action-gh-release@v1
with:
files: ${{ env.REPO_NAME }}-${{ env.TAG_NAME }}.zip