Skip to content

Commit 46f85f7

Browse files
authored
Add GitHub Actions workflow for publishing images
1 parent 0e93fd7 commit 46f85f7

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish Challenge Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "*/Dockerfile"
8+
- "*/requirements.txt"
9+
- "*/app/**"
10+
- ".github/workflows/publish-images.yml"
11+
workflow_dispatch:
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
16+
jobs:
17+
detect-challenges:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
challenges: ${{ steps.find.outputs.challenges }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- id: find
24+
run: |
25+
challenges=$(ls -d */ | grep -v '_template\|\.github' | sed 's/\///' | jq -R -s -c 'split("\n") | map(select(length >
26+
0))')
27+
echo "challenges=$challenges" >> "$GITHUB_OUTPUT"
28+
29+
build-and-push:
30+
needs: detect-challenges
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read
34+
packages: write
35+
strategy:
36+
matrix:
37+
challenge: ${{ fromJson(needs.detect-challenges.outputs.challenges) }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: docker/setup-buildx-action@v3
42+
43+
- uses: docker/login-action@v3
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ${{ env.REGISTRY }}/kryptsec/oasis-challenges/${{ matrix.challenge }}
53+
tags: |
54+
type=raw,value=latest,enable={{is_default_branch}}
55+
type=sha,prefix=
56+
57+
- uses: docker/build-push-action@v6
58+
with:
59+
context: ./${{ matrix.challenge }}
60+
push: true
61+
platforms: linux/amd64
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)