Delete Docker Tags with Wildcard #15
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
name: Delete Docker Tags with Wildcard | |
on: | |
delete: | |
branches: | |
- "**" | |
workflow_dispatch: | |
inputs: | |
tag_pattern: | |
description: 'Wildcard pattern for Docker tags to delete' | |
required: true | |
default: "branch-name" | |
jobs: | |
find-images: | |
name: Find docker images needing deleted | |
runs-on: ubuntu-latest | |
outputs: | |
images: ${{ steps.images.outputs.images }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Find docker files | |
id: images | |
run: | | |
images=$(find examples -name Dockerfile | jq -c --raw-input --slurp 'split("\n")| .[0:-1]' | jq -r '.[]' | \ | |
awk -F'/' '{print "scyllaridae-" $2}' | \ | |
jq -c -R -s '. | split("\n") | .[0:-1] | . + ["scyllaridae"]') | |
echo "images=$images" >> $GITHUB_OUTPUT | |
delete-docker-tags: | |
needs: [find-images] | |
runs-on: ubuntu-latest | |
strategy: | |
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 | |
- name: Get branch | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "BRANCH_NAME=${{ github.event.inputs.tag_pattern }}" >> $GITHUB_ENV | |
else | |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
fi | |
- name: Delete Docker Tags | |
run: ./ci/delete-tags.sh | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_REPOSITORY: "lehighlts" | |
DOCKER_IMAGE: ${{ matrix.image }} | |
TAG_PATTERN: "^${{ env.BRANCH_NAME }}.*" |