-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (34 loc) · 1.28 KB
/
release-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Build and Publish Docker Images
on:
push:
branches:
- main
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Publish Docker Images
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
for dir in */; do
dir=${dir%*/}
image_name=dapr-microservices/$(echo $dir | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]')
repo_owner=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
tag=${{ github.sha }}
tag="latest"
dockerfile_path="./$dir/Dockerfile"
if [ -f "$dockerfile_path" ]; then
echo "Building Docker image for $dir"
docker buildx build -t ghcr.io/$repo_owner/$image_name:$tag -f "$dockerfile_path" "$dir" -o type=registry
else
echo "Skipping build for $dir - Dockerfile not found"
fi
done
env:
BUILDKIT_INLINE_CACHE: 1