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

fixup delete #54

Merged
merged 7 commits into from
Nov 16, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@ on:
tag_pattern:
description: 'Wildcard pattern for Docker tags to delete'
required: true
default: "^branch-name.*"
default: "branch-name"

jobs:
find-images:
name: Find docker images needing deleted
runs-on: ubuntu-latest
outputs:
dockerFiles: ${{ steps.images.outputs.images }}
images: ${{ steps.images.outputs.images }}
steps:
- uses: actions/checkout@v4

- name: Find docker files
id: images
run: |
dockerFiles=$(find examples -name Dockerfile | jq -c --raw-input --slurp 'split("\n")| .[0:-1]')
images=$(echo "$dockerFiles" | jq -r '.[]' | \
images=$(find examples -name Dockerfile | jq -c --raw-input --slurp 'split("\n")| .[0:-1]' | jq -r '.[]' | \
awk -F'/' '{print "scyllaridae-" $2}' | \
jq -R -s '. | split("\n") | .[0:-1] | . + ["scyllaridae"]')
jq -c -R -s '. | split("\n") | .[0:-1] | . + ["scyllaridae"]')
echo "images=$images" >> $GITHUB_OUTPUT

delete-docker-tags:
Expand All @@ -36,6 +35,7 @@ jobs:
matrix:
image: ${{ fromJson(needs.find-images.outputs.images )}}
max-parallel: 1 # go easy on the dockerhub API
fail-fast: false
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -44,7 +44,7 @@ jobs:
run: ./ci/delete-tags.sh
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: "lehighlts"
DOCKER_IMAGE: ${{ matrix.image }}
TAG_PATTERN: "^${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_pattern || github.ref_name }}.*"
1 change: 1 addition & 0 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
paths-ignore:
- '**/*.md'
- 'ci/**'
- '.github/workflows/delete.yml'
tags:
- '*'
branches:
Expand Down
4 changes: 2 additions & 2 deletions ci/delete-tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi

echo "Deleting tags matching pattern '$TAG_PATTERN' in repository ${DOCKER_IMAGE}"

curl -s -o response.json -u "${DOCKER_USERNAME}:${DOCKER_ACCESS_TOKEN}" "https://hub.docker.com/v2/repositories/${DOCKER_REPOSITORY}/${DOCKER_IMAGE}/tags?page_size=100"
curl -s -o response.json -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" "https://hub.docker.com/v2/repositories/${DOCKER_REPOSITORY}/${DOCKER_IMAGE}/tags?page_size=100"
TAGS=$(jq -r '.results[].name' response.json)
if [ -z "$TAGS" ] || [ "$TAGS" = "null" ]; then
echo "No tags found or failed to retrieve tags."
Expand All @@ -18,7 +18,7 @@ fi

curl -s -o token.json -XPOST \
-H "Content-Type: application/json" \
-d '{"username": "'"${DOCKER_USERNAME}"'", "password": "'"${DOCKER_ACCESS_TOKEN}"'"}' \
-d '{"username": "'"${DOCKER_USERNAME}"'", "password": "'"${DOCKER_PASSWORD}"'"}' \
"https://hub.docker.com/v2/users/login"

TOKEN=$(jq -r .token token.json)
Expand Down