11
11
LOGDIR : /var/tmp/packer-templates-logs
12
12
VAGRANT_CLOUD_USER : peru
13
13
VAGRANT_CLOUD_TOKEN : ${{ secrets.VAGRANT_CLOUD_TOKEN }}
14
- # Needed for Packer when calling ansible
14
+ # Needed for Packer when calling ansible (https://github.com/ansible/ansible/issues/32499)
15
15
OBJC_DISABLE_INITIALIZE_FORK_SAFETY : YES
16
16
17
17
jobs :
@@ -104,90 +104,6 @@ jobs:
104
104
# #############
105
105
106
106
build-virtualbox :
107
- name : " *"
108
- runs-on : [self-hosted, linux, x64]
109
- needs : build-libvirt
110
- strategy :
111
- max-parallel : 1
112
- fail-fast : false
113
- matrix :
114
- stage :
115
- - my_ubuntu-20.04-server-amd64-virtualbox
116
- - my_windows-10-enterprise-x64-eval-virtualbox
117
- - ubuntu-16.04-server-amd64-virtualbox
118
- - ubuntu-18.04-desktop-amd64-virtualbox
119
- - ubuntu-18.04-server-amd64-virtualbox
120
- - ubuntu-20.04-desktop-amd64-virtualbox
121
- - ubuntu-20.04-server-amd64-virtualbox
122
- - windows-10-enterprise-x64-eval-virtualbox
123
- - windows-server-2012_r2-standard-x64-eval-virtualbox
124
- - windows-server-2016-standard-x64-eval-virtualbox
125
- - windows-server-2019-standard-x64-eval-virtualbox
126
-
127
- steps :
128
- - name : Skip image build if it already exists in Vagrant Cloud
129
- run : |
130
- BUILD="${{ matrix.stage }}"
131
- PACKER_VAGRANT_PROVIDER="${BUILD##*-}"
132
- NAME="${BUILD%-*}"
133
-
134
- # Check if the boxes (virtualbox/libvirt) with the same git hash already exists
135
- CURRENT_VERSION_DESCRIPTION_MARKDOWN="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq '.current_version.version as $current_version | .versions[] | select (.version == $current_version) .description_markdown')"
136
- if [[ "${CURRENT_VERSION_DESCRIPTION_MARKDOWN}" =~ ${GITHUB_SHA} ]] ; then
137
- echo "*** Git hash \"${GITHUB_SHA}\" found in current markdown description"
138
- # Skip build if the box already exists
139
- CURRENT_VERSION_PROVIDER_URL="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq -r ".current_version.version as \$current_version | .versions[] | select (.version == \$current_version) .providers[] | select (.name == \"${PACKER_VAGRANT_PROVIDER}\") .download_url")"
140
- if [ -n "${CURRENT_VERSION_PROVIDER_URL}" ]; then
141
- echo "*** Found already build image \"${BUILD}\" with hash \"${GITHUB_SHA}\": ${CURRENT_VERSION_PROVIDER_URL}"
142
- echo "*** This build will be skipped..."
143
- echo "::set-env name=skip::true"
144
- else
145
- # Set BOX_VERSION variable from existing provider (if exists) or from "date"
146
- BOX_VERSION="$(curl -L --silent "https://app.vagrantup.com/api/v1/box/${VAGRANT_CLOUD_USER}/${NAME}" | jq -r ".current_version.version")"
147
- echo "*** Using previously defined box version \"${BOX_VERSION}\", because there is already builded box with git hash \"${GITHUB_SHA}\""
148
- fi
149
- else
150
- BOX_VERSION="$(date +%Y%m%d).01"
151
- echo "*** Using new box version based on current date: ${BOX_VERSION}"
152
- fi
153
- echo "::set-env name=BOX_VERSION::${BOX_VERSION}"
154
-
155
- - uses : actions/checkout@v2
156
- if : env.skip != 'true'
157
- with :
158
- submodules : true
159
-
160
- - name : Build image - ${{ matrix.stage }}
161
- if : env.skip != 'true'
162
- run : |
163
- test -d "${PACKER_CACHE_DIR}" || mkdir -v "${PACKER_CACHE_DIR}"
164
- ln -sv "${PACKER_CACHE_DIR}" packer_cache
165
- ./build.sh "${{ matrix.stage }}" || ./build.sh "${{ matrix.stage }}"
166
-
167
- - name : Check the created box image - ${{ matrix.stage }}
168
- if : env.skip != 'true'
169
- run : |
170
- ./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
171
-
172
- - name : Upload box to Vagrant Cloud - ${{ matrix.stage }}
173
- if : env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) )
174
- env :
175
- BOX_VERSION : ${{ env.BOX_VERSION }}
176
- run : |
177
- ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" || ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
178
-
179
- - name : Build log cleanup - ${{ matrix.stage }}
180
- if : env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) )
181
- run : |
182
- rm -v "${LOGDIR}/${{ matrix.stage }}-packer.log"
183
- rm -v "${LOGDIR}/${{ matrix.stage }}-init.log"
184
- rm -v "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
185
-
186
- # ###############
187
- # VirtualBox 2
188
- # ###############
189
-
190
- build-virtualbox2 :
191
107
name : " *"
192
108
runs-on : macos-latest
193
109
strategy :
@@ -257,9 +173,16 @@ jobs:
257
173
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:${PATH}
258
174
./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
259
175
176
+ - name : Upload box to Vagrant Cloud - ${{ matrix.stage }}
177
+ if : env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) )
178
+ env :
179
+ BOX_VERSION : ${{ env.BOX_VERSION }}
180
+ run : |
181
+ ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" || ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
182
+
260
183
cleanup :
261
184
runs-on : [self-hosted, linux, x64]
262
- needs : [ build-libvirt, build-virtualbox]
185
+ needs : build-libvirt
263
186
if : always()
264
187
steps :
265
188
- uses : actions/checkout@v2
@@ -269,7 +192,7 @@ jobs:
269
192
./tools/cleanup_all_vms.sh
270
193
271
194
clean_check_versions :
272
- needs : build-virtualbox
195
+ needs : [ build-libvirt, build- virtualbox]
273
196
runs-on : ubuntu-latest
274
197
steps :
275
198
- name : Remove old versions
0 commit comments