1818 build-context :
1919 runs-on : ubuntu-latest
2020 outputs :
21- push_image : ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) || (github.event_name == 'release' && github.event.action == 'created ') }}
21+ push_image : ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) || (github.event_name == 'release' && github.event.action == 'published ') }}
2222 steps :
2323 - name : Dump GitHub context
2424 env :
@@ -32,55 +32,60 @@ jobs:
3232 steps :
3333 - name : Checkout code
3434 uses : actions/checkout@v3
35-
35+
3636 - name : Env seen prerun
3737 run : env
38-
38+
3939 - name : Get branch name
4040 id : branch-name
4141 uses :
tj-actions/[email protected] 42-
42+
4343 - name : Current branch name
4444 run : |
4545 echo "Current Branch: ${{ steps.branch-name.outputs.current_branch }}"
4646 echo "Target Branch: ${{ steps.branch-name.outputs.base_ref_branch }}"
4747 echo "Tag if exist: ${{ steps.branch-name.outputs.tag }}"
48-
48+
4949 - name : Running on a tag.
5050 if : steps.branch-name.outputs.is_tag == 'true'
5151 run : |
5252 echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
5353 echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
54-
54+
5555 - name : Running on a branch and merge.
56- if : steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push'
56+ if : steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main'
5757 run : |
5858 echo "TAG_NAME=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV}
5959 echo "TAG_LATEST=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV}
6060
61+ - name : Running on main branch.
62+ if : steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch == 'main'
63+ run : |
64+ echo "TAG_NAME=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV}
65+ echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
66+
6167 - name : Running on a branch and pull req.
62- if : steps.branch-name.outputs.is_tag != 'true' && github.event_name != 'push'
68+ if : steps.branch-name.outputs.is_tag != 'true' && github.event_name != 'push'
6369 run : |
6470 echo "TAG_NAME=${{ steps.branch-name.outputs.base_ref_branch }}" >> ${GITHUB_ENV}
6571 echo "TAG_LATEST=${{ steps.branch-name.outputs.base_ref_branch }}" >> ${GITHUB_ENV}
66-
67-
72+
6873 # setup Docker build action
6974 - name : Set up Docker Buildx
7075 id : buildx
7176 uses : docker/setup-buildx-action@v1
7277 - name : Set up QEMU
7378 id : qemu
7479 uses : docker/setup-qemu-action@v1
75-
80+
7681 - name : Login to DockerHub
7782 if : needs.build-context.outputs.push_image == 'true'
7883 uses : docker/login-action@v1
7984 with :
8085 username : ${{ secrets.DOCKERHUB_USERNAME }}
8186 password : ${{ secrets.DOCKERHUB_TOKEN }}
82-
83- - name : Build crapi-identity image
87+
88+ - name : Build crapi-identity image
8489 uses : docker/build-push-action@v2
8590 with :
8691 context : ./services/identity
9095 platforms : linux/amd64
9196 cache-from : type=gha
9297 cache-to : type=gha,mode=max
93-
94- - name : Build crapi-workshop image
98+
99+ - name : Build crapi-workshop image
95100 uses : docker/build-push-action@v2
96101 with :
97102 context : ./services/workshop
@@ -101,8 +106,8 @@ jobs:
101106 platforms : linux/amd64
102107 cache-from : type=gha
103108 cache-to : type=gha,mode=max
104-
105- - name : Build crapi-community image
109+
110+ - name : Build crapi-community image
106111 uses : docker/build-push-action@v2
107112 with :
108113 context : ./services/community
@@ -112,8 +117,8 @@ jobs:
112117 platforms : linux/amd64
113118 cache-from : type=gha
114119 cache-to : type=gha,mode=max
115-
116- - name : Build crapi-web image
120+
121+ - name : Build crapi-web image
117122 uses : docker/build-push-action@v2
118123 with :
119124 context : ./services/web
@@ -129,8 +134,8 @@ jobs:
129134 uses : andstor/file-existence-action@v1
130135 with :
131136 files : " ./services/mailhog"
132-
133- - name : Build mailhog image
137+
138+ - name : Build mailhog image
134139 if : steps.check_mailhog_exists.outputs.files_exists == 'true'
135140 uses : docker/build-push-action@v2
136141 with :
@@ -141,13 +146,13 @@ jobs:
141146 platforms : linux/amd64
142147 cache-from : type=gha
143148 cache-to : type=gha,mode=max
144-
149+
145150 - name : Show all images built
146151 run : docker images
147-
152+
148153 - name : Env seen
149154 run : env
150-
155+
151156 - name : Run crAPI using built images
152157 run : VERSION=${{ env.TAG_NAME }} docker-compose -f deploy/docker/docker-compose.yml --compatibility up -d
153158
@@ -171,7 +176,7 @@ jobs:
171176 platforms : ${{ env.PLATFORMS }}
172177 cache-from : type=gha
173178 cache-to : type=gha,mode=max
174-
179+
175180 - name : Build crapi-workshop all platforms and conditionally push to Docker Hub
176181 uses : docker/build-push-action@v2
177182 with :
@@ -181,7 +186,7 @@ jobs:
181186 platforms : ${{ env.PLATFORMS }}
182187 cache-from : type=gha
183188 cache-to : type=gha,mode=max
184-
189+
185190 - name : Build crapi-community all platforms and conditionally push to Docker Hub
186191 uses : docker/build-push-action@v2
187192 with :
@@ -191,7 +196,7 @@ jobs:
191196 platforms : ${{ env.PLATFORMS }}
192197 cache-from : type=gha
193198 cache-to : type=gha,mode=max
194-
199+
195200 - name : Build crapi-web all platforms and conditionally push to Docker Hub
196201 uses : docker/build-push-action@v2
197202 with :
@@ -212,4 +217,4 @@ jobs:
212217 platforms : ${{ env.PLATFORMS }}
213218 cache-from : type=gha
214219 cache-to : type=gha,mode=max
215-
220+
0 commit comments