Skip to content

Commit 7c7b385

Browse files
Merge pull request #212 from blacklanternsecurity/dev
Dev -> Stable 8.7.0
2 parents 77264a3 + 9b4d768 commit 7c7b385

28 files changed

Lines changed: 4446 additions & 85 deletions

.github/workflows/docker-tests.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Docker Tests
2+
3+
on:
4+
push:
5+
branches: [ stable ]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
docker-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Install dependencies
25+
run: |
26+
pip install requests
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Run Docker tests
32+
run: |
33+
python test_docker.py
34+
35+
docker-publish:
36+
runs-on: ubuntu-latest
37+
needs: docker-test
38+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/stable' }}
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v6
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log in to Docker Hub
48+
uses: docker/login-action@v3
49+
with:
50+
username: blacklanternsecurity
51+
password: ${{ secrets.DOCKER_TOKEN }}
52+
53+
- name: Extract metadata
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: blacklanternsecurity/cloudcheck
58+
tags: |
59+
type=ref,event=branch
60+
type=ref,event=pr
61+
type=sha,prefix=sha-
62+
type=raw,value=latest,enable={{is_default_branch}}
63+
type=raw,value=v1
64+
type=raw,value=v1.0
65+
type=raw,value=v1.0.0
66+
67+
- name: Build and push Docker image
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: .
71+
file: ./Dockerfile
72+
push: true
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
- name: Clean up old Docker Hub tags (up to 50 most recent tags plus 'latest')
79+
run: |
80+
# Install jq for JSON processing
81+
sudo apt-get update && sudo apt-get install -y jq
82+
83+
echo "Cleaning up blacklanternsecurity/cloudcheck tags..."
84+
85+
tags_response=$(curl -s -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" \
86+
"https://hub.docker.com/v2/repositories/blacklanternsecurity/cloudcheck/tags/?page_size=100")
87+
88+
tags_to_delete=$(echo "$tags_response" | jq -r '.results[] | select(.name != "latest") | [.last_updated, .name] | @tsv' | \
89+
sort -r | tail -n +11 | cut -f2)
90+
91+
for tag in $tags_to_delete; do
92+
echo "Deleting blacklanternsecurity/cloudcheck tag: $tag"
93+
curl -X DELETE -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" \
94+
"https://hub.docker.com/v2/repositories/blacklanternsecurity/cloudcheck/tags/$tag/"
95+
done
96+
97+
echo "Cleanup completed for blacklanternsecurity/cloudcheck. Kept 50 most recent tags plus 'latest'."

0 commit comments

Comments
 (0)