15
15
16
16
jobs :
17
17
deploy :
18
- needs : [validate_version, check_ci_success]
19
18
runs-on : ubuntu-latest
20
19
environment : DEV
21
20
steps :
21
+ - name : Validate version format
22
+ if : github.event_name == 'workflow_dispatch'
23
+ run : |
24
+ if [[ "${{ github.event.inputs.version }}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
25
+ echo "Version format is valid"
26
+ else
27
+ echo "Invalid version format. Use 'latest' or semver format (e.g., 0.2411.135)"
28
+ exit 1
29
+ fi
30
+
31
+ - name : Check CI success
32
+ if : github.event_name == 'workflow_run' && github.event.workflow_run.conclusion != 'success'
33
+ run : |
34
+ echo "CI failed"
35
+ exit 1
36
+
22
37
- name : Checkout repository
23
38
uses : actions/checkout@v2
24
39
@@ -103,7 +118,7 @@ jobs:
103
118
104
119
- name : Set deployed image version
105
120
id : set_version
106
- run : echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
121
+ run : echo "version=${{ steps.triggered_workflow_run.outputs.version || github.event.inputs.version }}" >> $GITHUB_OUTPUT
107
122
108
123
- name : Run Docker Compose up
109
124
id : deploy
@@ -115,7 +130,7 @@ jobs:
115
130
script : |
116
131
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
117
132
sudo docker-compose -f ~/app/bootstrap/http/compose-dev.yaml pull
118
- sudo VERSION=${{ github.event.inputs .version }} docker-compose -f ~/app/bootstrap/http/compose-dev.yaml up -d --force-recreate
133
+ sudo VERSION=${{ steps.set_version.outputs .version }} docker-compose -f ~/app/bootstrap/http/compose-dev.yaml up -d --force-recreate
119
134
120
135
- name : Send discord notification (develop server deploy failed)
121
136
if : failure() && steps.deploy.outcome == 'failure'
@@ -128,7 +143,7 @@ jobs:
128
143
>
129
144
> 🛢️ Repository : ${{ github.repository }}
130
145
> 🎋 Branch : ${{ github.ref }}
131
- > 📐 Version : ${{ github.event.inputs .version }}
146
+ > 📐 Version : ${{ steps.set_version.outputs .version }}
132
147
> 🔁 Run Attempt : ${{ github.run_attempt }}
133
148
> 🤗 Actor : ${{ github.triggering_actor }}
134
149
@@ -165,29 +180,6 @@ jobs:
165
180
>
166
181
> 🛢️ Repository : ${{ github.repository }}
167
182
> 🎋 Branch : ${{ github.ref }}
168
- > 📐 Version : ${{ github.event.inputs .version }}
183
+ > 📐 Version : ${{ steps.set_version.outputs .version }}
169
184
> 🔁 Run Attempt : ${{ github.run_attempt }}
170
185
> 🤗 Actor : ${{ github.triggering_actor }}
171
-
172
- validate_version :
173
- runs-on : ubuntu-latest
174
- if : github.event_name == 'workflow_dispatch'
175
- steps :
176
- - name : Validate version format
177
- run : |
178
- if [[ "${{ github.event.inputs.version }}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
179
- echo "Version format is valid"
180
- else
181
- echo "Invalid version format. Use 'latest' or semver format (e.g., 0.2411.135)"
182
- exit 1
183
- fi
184
-
185
- check_ci_success :
186
- needs : validate_version
187
- runs-on : ubuntu-latest
188
- steps :
189
- - name : Check CI
190
- if : ${{ github.event.workflow_run != null && github.event.workflow_run.conclusion != 'success' }}
191
- run : |
192
- echo "CI failed"
193
- exit 1
0 commit comments