Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 42ccece

Browse files
authored
Add git hash to templates + improve GH build process (#127)
1 parent b633cb4 commit 42ccece

9 files changed

+28
-10
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ jobs:
4545
BUILD="${{ matrix.stage }}"
4646
PACKER_VAGRANT_PROVIDER="${BUILD##*-}"
4747
NAME="${BUILD%-*}"
48-
BOX_VERSION="$(date +%Y%m%d).01"
49-
echo "*** $(hostname --short)"
50-
if curl -L --fail --silent --head --output /dev/null "https://vagrantcloud.com/${VAGRANT_CLOUD_USER}/boxes/${NAME}/versions/${BOX_VERSION}/providers/${PACKER_VAGRANT_PROVIDER}.box"; then
51-
echo "*** ${BUILD} exists on Vagrant Cloud"
52-
echo "::set-env name=skip::true"
48+
49+
# Check if the boxes (virtualbox/libvirt) with the same git sha already exists
50+
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')"
51+
if echo "${CURRENT_VERSION_DESCRIPTION_MARKDOWN}" | grep -q "${GITHUB_SHA}"; then
52+
# Skip build if the box already exists
53+
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")"
54+
if [ -n "${CURRENT_VERSION_PROVIDER_URL}" ]; then
55+
echo "*** ${BUILD} with git sha \"${GITHUB_SHA}\" exists on Vagrant Cloud"
56+
echo "::set-env name=skip::true"
57+
fi
5358
fi
5459
5560
- uses: actions/checkout@v2
@@ -113,11 +118,16 @@ jobs:
113118
BUILD="${{ matrix.stage }}"
114119
PACKER_VAGRANT_PROVIDER="${BUILD##*-}"
115120
NAME="${BUILD%-*}"
116-
BOX_VERSION="$(date +%Y%m%d).01"
117-
echo "*** $(hostname --short)"
118-
if curl -L --fail --silent --head --output /dev/null "https://vagrantcloud.com/${VAGRANT_CLOUD_USER}/boxes/${NAME}/versions/${BOX_VERSION}/providers/${PACKER_VAGRANT_PROVIDER}.box"; then
119-
echo "*** ${BUILD} exists on Vagrant Cloud"
120-
echo "::set-env name=skip::true"
121+
122+
# Check if the boxes (virtualbox/libvirt) with the same git sha already exists
123+
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')"
124+
if echo "${CURRENT_VERSION_DESCRIPTION_MARKDOWN}" | grep -q "${GITHUB_SHA}"; then
125+
# Skip build if the box already exists
126+
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")"
127+
if [ -n "${CURRENT_VERSION_PROVIDER_URL}" ]; then
128+
echo "*** ${BUILD} with git sha \"${GITHUB_SHA}\" exists on Vagrant Cloud"
129+
echo "::set-env name=skip::true"
130+
fi
121131
fi
122132
123133
- uses: actions/checkout@v2

templates/my_centos.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

templates/my_ubuntu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
88
## GitHub repository for bug reports or feature requests
99

1010
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
11+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1112

1213
## Requirements
1314

templates/my_windows-10-enterprise-eval.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

templates/ubuntu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Clean + Minimal + Latest Ubuntu ${UBUNTU_TYPE_UC} ${UBUNTU_ARCH} base box for
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

templates/windows-10-enterprise-eval.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

templates/windows-server-2012-eval.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
1010
## GitHub repository for bug reports or feature requests
1111

1212
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
13+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1314

1415
## Requirements
1516

templates/windows-server-2016-eval.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

templates/windows-server-2019-eval.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and [VirtualBox](https://www.vagrantup.com/docs/virtualbox/) Vagrant providers.
99
## GitHub repository for bug reports or feature requests
1010

1111
* [https://github.com/ruzickap/packer-templates/](https://github.com/ruzickap/packer-templates/)
12+
* Git commit hash: [${GITHUB_SHA}](https://github.com/ruzickap/packer-templates/commit/${GITHUB_SHA})
1213

1314
## Requirements
1415

0 commit comments

Comments
 (0)