Skip to content

Commit 4ba9f1a

Browse files
authored
Merge pull request #8 from useblacksmith/add-stickydisk-demo-workflows
Add demo workflows for stickydisk usage and deletion
2 parents d76845d + a55db7d commit 4ba9f1a

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.github/workflows/demo-docker.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Demo Docker Cache with Stickydisk
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
demo-docker-cache:
10+
name: Demo Docker Build Cache with Deletion
11+
runs-on: blacksmith-staging
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Builder
17+
uses: useblacksmith/setup-docker-builder@v1
18+
19+
- name: Create Sample Dockerfile
20+
run: |
21+
cat > Dockerfile << 'EOF'
22+
FROM alpine:latest
23+
24+
# Create a simple hello world script.
25+
RUN echo '#!/bin/sh' > /hello.sh && \
26+
echo 'echo "Hello from Stickydisk Demo!"' >> /hello.sh && \
27+
echo 'echo "This demonstrates Docker build cache management."' >> /hello.sh && \
28+
chmod +x /hello.sh
29+
30+
CMD ["/hello.sh"]
31+
EOF
32+
33+
- name: Build Docker Image with Cache
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
push: false
38+
tags: stickydisk-delete:latest
39+
cache-from: type=gha
40+
cache-to: type=gha,mode=max
41+
42+
- name: Verify Docker Build
43+
run: |
44+
echo "Docker image built successfully."
45+
docker images
46+
echo ""
47+
echo "Looking for stickydisk-delete image:"
48+
docker images | grep stickydisk-delete || echo "Image may have been built with a different tag"
49+
50+
- name: Delete Docker Build Cache
51+
uses: useblacksmith/stickydisk-delete@main
52+
with:
53+
delete-docker-cache: true
54+
55+
- name: Verify Cache Deletion
56+
run: |
57+
echo "Docker build cache for ${{ github.repository }} has been deleted."
58+
echo "The next build will not benefit from cached layers."

.github/workflows/demo.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Demo Stickydisk Usage and Deletion
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
demo-stickydisk:
10+
name: Demo Stickydisk with Deletion
11+
runs-on: blacksmith-staging
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Mount Stickydisk
17+
uses: useblacksmith/stickydisk@v1
18+
with:
19+
key: ${{ github.repository }}-demo-cache
20+
path: ./demo-cache
21+
22+
- name: Write Data to Stickydisk
23+
run: |
24+
echo "Creating demo files in stickydisk..."
25+
mkdir -p ./demo-cache/data
26+
echo "Hello from stickydisk!" > ./demo-cache/data/test.txt
27+
echo "Timestamp: $(date)" >> ./demo-cache/data/test.txt
28+
echo "Workflow run: ${{ github.run_number }}" >> ./demo-cache/data/test.txt
29+
30+
# Create some additional files.
31+
for i in {1..5}; do
32+
echo "Sample data file $i" > ./demo-cache/data/file$i.txt
33+
done
34+
35+
echo "Files created in stickydisk:"
36+
ls -lah ./demo-cache/data/
37+
38+
- name: Read Data from Stickydisk
39+
run: |
40+
echo "Reading data from stickydisk..."
41+
cat ./demo-cache/data/test.txt
42+
echo ""
43+
echo "Total files in cache:"
44+
find ./demo-cache -type f | wc -l
45+
46+
- name: Delete Stickydisk
47+
uses: useblacksmith/stickydisk-delete@main
48+
with:
49+
delete-key: ${{ github.repository }}-demo-cache
50+
51+
- name: Verify Deletion
52+
run: |
53+
echo "Stickydisk with key '${{ github.repository }}-demo-cache' has been deleted."
54+
echo "This cache will not persist to the next workflow run."

0 commit comments

Comments
 (0)