-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes entrypoint of packetrusher and adds image info automation (#232)
- Loading branch information
1 parent
4a87fe2
commit fbc9535
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
IMAGE_TAG=97f9f0c | ||
#comma separated list of platforms. If empty, image will not be multiarch. | ||
PLATFORMS= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#/bin/bash | ||
|
||
REMOTE_REPO_URL="https://api.github.com/repos/HewlettPackard/PacketRusher/commits?sha=main" | ||
|
||
GH="https://api.github.*" | ||
GL="https://gitlab.*" | ||
|
||
# Fetch the last version available on the remote repository | ||
if [[ ${REMOTE_REPO_URL} =~ ${GH} ]] ; then | ||
CURRENT_TAG=$( curl -sSL ${REMOTE_REPO_URL} | jq -r '.[0].sha' | sed 's/^\(.\{7\}\).*/\1/' ) | ||
# sed explanation | ||
# -n dont print anything | ||
# /v[0-9.]\+/h; every match with "v[0-9.]\+" gets stored on hold | ||
# $g; replace contents of pattern space with hold space, adds last match as last line to buffer | ||
# s//\1/; replace pattern, removes everything around version | ||
# $p only last line is printed | ||
elif [[ ${REMOTE_REPO_URL} =~ ${GL} ]] ; then | ||
CURRENT_TAG=$( curl -sSL ${REMOTE_REPO_URL} | jq -r '.[0].sha' | sed 's/^\(.\{7\}\).*/\1/' ) | ||
else | ||
echo "Error Reading URL" | ||
exit 1 | ||
fi | ||
|
||
# Load IMAGE_TAG | ||
[[ -f image_info.sh ]] && source image_info.sh || exit 1 | ||
|
||
|
||
# Compare CURRENT_TAG with saved IMAGE_TAG | ||
[[ ${CURRENT_TAG} == ${IMAGE_TAG} ]] || { | ||
echo "Updating old TAG ${IMAGE_TAG} with new TAG ${CURRENT_TAG}" | ||
sed -i "/IMAGE_TAG/s/=.*$/=${CURRENT_TAG}/" image_info.sh | ||
exit 0 | ||
} | ||
|
||
# Fail otherwise | ||
exit 1 |