-
Notifications
You must be signed in to change notification settings - Fork 9
159 lines (131 loc) · 6.45 KB
/
Build_and_Publish_Images.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build and Publish Docker Image
on:
release:
types:
- published
- edited
jobs:
build-and-publish-release:
runs-on: ubuntu-latest
if: startsWith(github.event.release.name, 'Seed-Test_v')
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies
run: npm install node-fetch
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Tag Name
id: get_tag_name
run: |
version=$(echo $GITHUB_REF | sed 's/refs\/tags\///' | sed 's/.*_//')
echo "version=${version}" >> ${GITHUB_OUTPUT}
# BACKEND
- name: Build Docker Image
run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend
- name: Tag Docker Image as Latest
run: |
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest
# FRONTEND
- name: Build Docker Image
run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend
- name: Tag Docker Image as Latest
run: |
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest
# SINGLE QUICK DEMO CONTAINER
- name: Build Docker Image as Latest
run: |
docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} .
- name: Tag Docker Image as Latest
run: |
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest
- name: Post susccess message
uses: ./actions/notifyTeams
with:
title: "Publish Release DockerHub 🐳🌐"
text: "Publishing Images for release ${{ github.event.release.name }} successfully."
style: "success"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
- name: Post error message
if: ${{ failure() }}
uses: ./actions/notifyTeams
with:
title: "Publish Release DockerHub 🐳🌐❌"
text: "Publishing Images for release ${{ github.event.release.name }} failed."
style: "failure"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
build-and-publish-test:
runs-on: ubuntu-latest
if: startsWith(github.event.release.name, 'Test_v')
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies
run: npm install node-fetch
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Tag Name
id: get_tag_name
run: |
version=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
echo "version=${version}" >> ${GITHUB_OUTPUT}
# BACKEND
- name: Build Docker Image
run: |
docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
# FRONTEND
- name: Build Docker Image
run: |
docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
# SINGLE QUICK DEMO CONTAINER
- name: Build Docker Image as Latest
run: |
docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} .
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
- name: Post susccess message
uses: ./actions/notifyTeams
with:
title: "Publish Test-Release DockerHub 🧪🐳🌐"
text: "Publishing Images for test-release ${{ github.event.release.name }} successfully."
style: "success"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
- name: Post error message
if: ${{ failure() }}
uses: ./actions/notifyTeams
with:
title: "Publish Test-Release DockerHub 🐳🌐❌"
text: "Publishing Images for test-release ${{ github.event.release.name }} failed."
style: "failure"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}