Skip to content

Commit

Permalink
Trying to fix workflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
craigk5n committed Sep 27, 2023
1 parent ba12a67 commit ffcc233
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ jobs:
KEEP_LAST_N_IMAGES: 5
run: |
# Get list of tags
TAGS=$(curl -s -u $DOCKER_HUB_USERNAME:$DOCKER_HUB_PASSWORD https://hub.docker.com/v2/repositories/$DOCKER_HUB_REPO/tags/?page_size=100 | jq -r '.results[].name')
RESPONSE=$(curl -s -u $DOCKER_HUB_USERNAME:$DOCKER_HUB_PASSWORD -o /tmp/response.json -w "%{http_code}" https://hub.docker.com/v2/repositories/$DOCKER_HUB_REPO/tags/?page_size=100)
# Check HTTP Status Code
if [ "$RESPONSE" -ne 200 ]; then
echo "Failed to fetch tags, HTTP Response code is $RESPONSE"
cat /tmp/response.json
exit 1
fi
# Check for null JSON Response and Extract Tags
TAGS=$(jq -r '.results? | if type=="array" then .[].name else empty end' /tmp/response.json)
# Filter tags with "dev"
DEV_TAGS=$(echo "$TAGS" | grep dev)
# Sort tags and delete all except for the most recent N
COUNTER=0
for TAG in $(echo $TAGS | tr " " "\n" | sort -V)
for TAG in $(echo $DEV_TAGS | tr " " "\n" | sort -V)
do
if [ $COUNTER -ge $KEEP_LAST_N_IMAGES ]
then
Expand Down

0 comments on commit ffcc233

Please sign in to comment.