Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry commands when build / upload failed in build.yml #161

Merged
merged 1 commit into from
Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Check the created box image - ${{ matrix.stage }}
if: env.skip != 'true'
run: |
./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box" || ./vagrant_init_destroy_boxes.sh "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"

- name: Upload box to Vagrant Cloud - ${{ matrix.stage }}
env:
Expand All @@ -96,9 +96,7 @@ jobs:
run: |
rm -v "${LOGDIR}/${{ matrix.stage }}-packer.log"
rm -v "${LOGDIR}/${{ matrix.stage }}-init.log"
if [[ ! "$( ls -A "${LOGDIR}" )" ]]; then rmdir -v "${LOGDIR}"; fi
rm -v "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
if [[ ! "$( ls -A "${PACKER_IMAGES_OUTPUT_DIR}" )" ]]; then rmdir -v "${PACKER_IMAGES_OUTPUT_DIR}"; fi

##############
# VirtualBox
Expand Down Expand Up @@ -164,7 +162,7 @@ jobs:
run: |
test -d "${PACKER_CACHE_DIR}" || mkdir -v "${PACKER_CACHE_DIR}"
ln -sv "${PACKER_CACHE_DIR}" packer_cache
./build.sh "${{ matrix.stage }}"
./build.sh "${{ matrix.stage }}" || ./build.sh "${{ matrix.stage }}"

- name: Check the created box image - ${{ matrix.stage }}
if: env.skip != 'true'
Expand All @@ -176,16 +174,14 @@ jobs:
env:
BOX_VERSION: ${{ env.BOX_VERSION }}
run: |
./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" || ./upload_box_to_vagrantcloud.sh "${VAGRANT_CLOUD_USER}@${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"

- name: Build log cleanup - ${{ matrix.stage }}
if: env.skip != 'true' && ( github.event_name == 'schedule' || ( github.event_name == 'repository_dispatch' && github.event.action == 'build_release_upload' ) )
run: |
rm -v "${LOGDIR}/${{ matrix.stage }}-packer.log"
rm -v "${LOGDIR}/${{ matrix.stage }}-init.log"
if [[ ! "$( ls -A "${LOGDIR}" )" ]]; then rmdir -v "${LOGDIR}"; fi
rm -v "${PACKER_IMAGES_OUTPUT_DIR}/${{ matrix.stage }}.box"
if [[ ! "$( ls -A "${PACKER_IMAGES_OUTPUT_DIR}" )" ]]; then rmdir -v "${PACKER_IMAGES_OUTPUT_DIR}"; fi

cleanup:
runs-on: [self-hosted, linux, x64]
Expand Down
4 changes: 2 additions & 2 deletions tools/cleanup_all_vms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if [[ -d "${TMPDIR}" ]]; then
fi

echo "*** Remove logs created by vagrant_init_destroy_boxes.sh form \"${LOGDIR}\""
find "${LOGDIR}" -maxdepth 1 -mindepth 1 -name "*-init.log" -delete
test -d "${LOGDIR}" && find "${LOGDIR}" -maxdepth 1 -mindepth 1 -name "*-init.log" -delete

echo "*** Remove all PACKER_CACHE_DIR mess (not the iso files)"
find "${PACKER_CACHE_DIR}" -mindepth 1 ! \( -type f -name "*.iso" \) -user "${USER}" -delete -print
test -d "${PACKER_CACHE_DIR}" && find "${PACKER_CACHE_DIR}" -mindepth 1 ! \( -type f -name "*.iso" \) -user "${USER}" -delete -print

echo "*** Remove all Vagrant boxes"
while IFS= read -r BOX; do
Expand Down