forked from osrf/mbzirc
-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (154 loc) · 6.77 KB
/
main.yml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
name: Release to dockerhub
on:
push:
tags:
- dockerhub_release_* # Launch dockerhub push on dockerhub_release_* tags
jobs:
build_docker_image:
runs-on: ubuntu-latest
env:
registry: osrf/mbzirc
strategy:
matrix:
image_name_sim: ['mbzirc_sim']
image_name_models: ['mbzirc_models']
image_name_cloud_sim: ['cloudsim_sim']
image_name_cloud_bridge: ['cloudsim_bridge']
steps:
- name: Safety check for uploads of forks
run: |
if [ "${{ env.registry }}" == "osrf/mbzirc" ] && \
[ "${{ github.repository }}" != "osrf/mbzirc" ]; then \
exit -1; \
fi
- name: Checkout sources
uses: actions/checkout@v2
- name: Install docker
uses: docker-practice/actions-setup-docker@master
# build mbzirc_models and push to dockerhub
- name: Run build script for models
id: build_docker_models
run: |
bash -xe ./docker/build.bash ${{ matrix.image_name_models }}
echo "::set-output name=name::${{ matrix.image_name_models }}:latest"
- name: Create latest version tag for models
id: latest_tag_models
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_models }}_latest"
- name: Create dated version tag for models
id: timestamp_tag_models
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_models }}_$(date +'%F_%H%M')"
# Login leaves the token without encription. Works are under
# https://github.com/docker/login-action/issues/30. Solution seems to
# use the pass store for the secrets
# https://docs.docker.com/engine/reference/commandline/login/#credentials-store
- name: Login to docker hub
uses: docker/login-action@v1
if: success()
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Tag models docker images for latest and dated images in dockerhub
if: success()
run: |
docker tag ${{ steps.build_docker_models.outputs.name }} \
${{ steps.latest_tag_models.outputs.name }}
docker tag ${{ steps.build_docker_models.outputs.name }} \
${{ steps.timestamp_tag_models.outputs.name }}
- name: Push models to docker latest
if: success()
run: |
docker push ${{ steps.latest_tag_models.outputs.name }}
- name: Push models to docker timestamped version
if: success()
run: |
docker push ${{ steps.timestamp_tag_models.outputs.name }}
# build mbzirc_sim and push to dockerhub
- name: Run build script for sim
id: build_docker_sim
run: |
bash -xe ./docker/build.bash ${{ matrix.image_name_sim}}
echo "::set-output name=name::${{ matrix.image_name_sim}}:latest"
- name: Create latest version tag for sim
id: latest_tag_sim
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_sim}}_latest"
- name: Create dated version tag for sim
id: timestamp_tag_sim
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_sim }}_$(date +'%F_%H%M')"
- name: Tag sim docker images for latest and dated images in dockerhub
if: success()
run: |
docker tag ${{ steps.build_docker_sim.outputs.name }} \
${{ steps.latest_tag_sim.outputs.name }}
docker tag ${{ steps.build_docker_sim.outputs.name }} \
${{ steps.timestamp_tag_sim.outputs.name }}
- name: Push sim to docker latest
if: success()
run: |
docker push ${{ steps.latest_tag_sim.outputs.name }}
- name: Push sim to docker timestamped version
if: success()
run: |
docker push ${{ steps.timestamp_tag_sim.outputs.name }}
# build cloud sim image and push to dockerhub
- name: Run build script for cloud
id: build_docker_cloud_sim
run: |
bash -xe ./docker/build.bash ${{ matrix.image_name_cloud_sim}}
echo "::set-output name=name::${{ matrix.image_name_cloud_sim}}:latest"
- name: Create latest version tag for sim
id: latest_tag_cloud_sim
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_cloud_sim}}_latest"
- name: Create dated version tag for sim
id: timestamp_tag_cloud_sim
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_cloud_sim}}_$(date +'%F_%H%M')"
- name: Tag sim docker images for latest and dated images in dockerhub
if: success()
run: |
docker tag ${{ steps.build_docker_cloud_sim.outputs.name }} \
${{ steps.latest_tag_cloud_sim.outputs.name }}
docker tag ${{ steps.build_docker_cloud_sim.outputs.name }} \
${{ steps.timestamp_tag_cloud_sim.outputs.name }}
- name: Push cloudsim_cloud_sim to docker latest
if: success()
run: |
docker push ${{ steps.latest_tag_cloud_sim.outputs.name }}
- name: Push cloudsim_cloud_sim to docker timestamped version
if: success()
run: |
docker push ${{ steps.timestamp_tag_sim.outputs.name }}
# build cloud bridge image and push to dockerhub
- name: Run build script for cloud
id: build_docker_cloud_bridge
run: |
bash -xe ./docker/build.bash ${{ matrix.image_name_cloud_bridge}}
echo "::set-output name=name::${{ matrix.image_name_cloud_bridge}}:latest"
- name: Create latest version tag for sim
id: latest_tag_cloud_bridge
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_cloud_bridge}}_latest"
- name: Create dated version tag for sim
id: timestamp_tag_cloud_bridge
run: |
echo "::set-output name=name::${{ env.registry }}:${{ matrix.image_name_cloud_bridge}}_$(date +'%F_%H%M')"
- name: Tag sim docker images for latest and dated images in dockerhub
if: success()
run: |
docker tag ${{ steps.build_docker_cloud_bridge.outputs.name }} \
${{ steps.latest_tag_cloud_bridge.outputs.name }}
docker tag ${{ steps.build_docker_cloud_bridge.outputs.name }} \
${{ steps.timestamp_tag_cloud_bridge.outputs.name }}
- name: Push cloudsim_cloud_bridge to docker latest
if: success()
run: |
docker push ${{ steps.latest_tag_cloud_bridge.outputs.name }}
- name: Push cloudsim_cloud_bridge to docker timestamped version
if: success()
run: |
docker push ${{ steps.timestamp_tag_sim.outputs.name }}