5858 - uses : actions/checkout@v5
5959 with :
6060 fetch-depth : 0
61+ - name : Login to Docker Hub
62+ uses : docker/login-action@v3
63+ with :
64+ username : ${{ secrets.DOCKER_USERNAME }}
65+ password : ${{ secrets.DOCKER_PASSWORD }}
6166 - name : Set up Python
6267 uses : actions/setup-python@v6
6368 with :
@@ -83,24 +88,59 @@ jobs:
8388 uses : elgohr/Publish-Docker-Github-Action@v5
8489 with :
8590 name : blacklanternsecurity/bbot
86- username : ${{ secrets.DOCKER_USERNAME }}
87- password : ${{ secrets.DOCKER_PASSWORD }}
8891 tags : " latest,dev,${{ steps.version.outputs.BBOT_VERSION }}"
8992 - name : Publish to Docker Hub (stable)
9093 if : github.event_name == 'push' && github.ref == 'refs/heads/stable'
9194 uses : elgohr/Publish-Docker-Github-Action@v5
9295 with :
9396 name : blacklanternsecurity/bbot
94- username : ${{ secrets.DOCKER_USERNAME }}
95- password : ${{ secrets.DOCKER_PASSWORD }}
9697 tags : " stable,${{ steps.version.outputs.BBOT_VERSION }}"
98+ - name : Publish Full Docker Image to Docker Hub (dev)
99+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
100+ uses : elgohr/Publish-Docker-Github-Action@v5
101+ with :
102+ name : blacklanternsecurity/bbot
103+ dockerfile : Dockerfile.full
104+ tags : " latest-full,dev-full,${{ steps.version.outputs.BBOT_VERSION }}-full"
105+ - name : Publish Full Docker Image to Docker Hub (stable)
106+ if : github.event_name == 'push' && github.ref == 'refs/heads/stable'
107+ uses : elgohr/Publish-Docker-Github-Action@v5
108+ with :
109+ name : blacklanternsecurity/bbot
110+ dockerfile : Dockerfile.full
111+ tags : " stable-full,${{ steps.version.outputs.BBOT_VERSION }}-full"
97112 - name : Docker Hub Description
98113 if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
99114 uses : peter-evans/dockerhub-description@v5
100115 with :
101- username : ${{ secrets.DOCKER_USERNAME }}
102- password : ${{ secrets.DOCKER_PASSWORD }}
103116 repository : blacklanternsecurity/bbot
117+ - name : Clean up old Docker Hub tags (up to 50 most recent tags plus 'latest')
118+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
119+ run : |
120+ # Install jq for JSON processing
121+ sudo apt-get update && sudo apt-get install -y jq
122+
123+ IMAGE="blacklanternsecurity/bbot"
124+
125+ # Clean up dev tags (keep 50 most recent)
126+ for tag_pattern in "rc$" "rc-full$"; do
127+ echo "Cleaning up tags ending with $tag_pattern..."
128+
129+ tags_response=$(curl -s -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" \
130+ "https://hub.docker.com/v2/repositories/$IMAGE/tags/?page_size=100")
131+
132+ tags_to_delete=$(echo "$tags_response" | jq -r --arg pattern "$tag_pattern" \
133+ '.results[] | select(.name | test($pattern)) | [.last_updated, .name] | @tsv' | \
134+ sort -r | tail -n +51 | cut -f2)
135+
136+ for tag in $tags_to_delete; do
137+ echo "Deleting $IMAGE tag: $tag"
138+ curl -X DELETE -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" \
139+ "https://hub.docker.com/v2/repositories/$IMAGE/tags/$tag/"
140+ done
141+
142+ echo "Cleanup completed for tags ending with $tag_pattern. Kept 50 most recent."
143+ done
104144 outputs :
105145 BBOT_VERSION : ${{ steps.version.outputs.BBOT_VERSION }}
106146 publish_docs :
0 commit comments