-
Notifications
You must be signed in to change notification settings - Fork 13
34 lines (30 loc) · 1.28 KB
/
deployImage.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
name: Build and Push Docker Images to GitHub Container Registry when pushed to main
on:
push:
branches:
- main
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.FLYTE_BOT_USERNAME }}
password: ${{ secrets.FLYTE_BOT_PAT }}
- name: Iterate through top level directories and build Docker images
run: |
for dir in *; do
if [ -f "$dir/{{cookiecutter.project_name}}/Dockerfile" ]; then
echo "Building and pushing Docker image for $dir"
docker build -f $dir/{{cookiecutter.project_name}}/Dockerfile -t ghcr.io/${{ github.repository }}:${dir}-latest $dir/{{cookiecutter.project_name}}
docker tag ghcr.io/${{ github.repository }}:${dir}-latest ghcr.io/${{ github.repository }}:${dir}-${{ github.sha }}
docker push ghcr.io/${{ github.repository }}:${dir}-latest
docker push ghcr.io/${{ github.repository }}:${dir}-${{ github.sha }}
else
echo "Skipping $dir as it does not contain a Dockerfile"
fi
done