push
All checks were successful
Build and Push Docker Images / build-rust-latest (push) Has been skipped
All checks were successful
Build and Push Docker Images / build-rust-latest (push) Has been skipped
This commit is contained in:
parent
93b7710451
commit
40cfa5ec21
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
name: Build and Push Docker Images
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@ -8,13 +9,16 @@ on:
|
|||||||
- '.gitea/workflows/docker-build.yml'
|
- '.gitea/workflows/docker-build.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-rust-latest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: git.hofer.link/philipp/ci-images:rust-latest
|
if: github.event_name == 'push' && contains(github.event.commits[0].modified, 'rust-latest/Dockerfile')
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@ -22,26 +26,34 @@ jobs:
|
|||||||
username: ${{ secrets.USERNAME_GITEA }}
|
username: ${{ secrets.USERNAME_GITEA }}
|
||||||
password: ${{ secrets.PASSWORD_GITEA }}
|
password: ${{ secrets.PASSWORD_GITEA }}
|
||||||
|
|
||||||
- name: Find changed Dockerfiles
|
- name: Build and push rust-latest
|
||||||
id: find-changes
|
uses: docker/build-push-action@v4
|
||||||
run: |
|
with:
|
||||||
# Get list of changed files
|
context: ./rust-latest
|
||||||
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} || git diff --name-only HEAD~1 HEAD)
|
push: true
|
||||||
|
tags: git.hofer.link/philipp/ci-images:rust-latest
|
||||||
# Find directories with changed Dockerfiles
|
|
||||||
for file in $CHANGED_FILES; do
|
|
||||||
if [[ $file == */Dockerfile ]]; then
|
|
||||||
dir=$(echo $file | sed 's/\/Dockerfile$//')
|
|
||||||
echo "Building image for directory: $dir"
|
|
||||||
|
|
||||||
# Extract image name from directory
|
|
||||||
IMAGE_NAME=$(basename $dir)
|
|
||||||
echo "Building image: $IMAGE_NAME"
|
|
||||||
|
|
||||||
# Build and push the Docker image
|
|
||||||
docker build -t git.hofer.link/philipp/ci-images:$IMAGE_NAME $dir
|
|
||||||
docker push git.hofer.link/philipp/ci-images:$IMAGE_NAME
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
# Add more jobs for other images following the same pattern
|
||||||
|
# build-another-image:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# if: github.event_name == 'push' && contains(github.event.commits[0].modified, 'another-image/Dockerfile')
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout code
|
||||||
|
# uses: actions/checkout@v3
|
||||||
|
#
|
||||||
|
# - name: Set up Docker Buildx
|
||||||
|
# uses: docker/setup-buildx-action@v2
|
||||||
|
#
|
||||||
|
# - name: Login to Gitea Container Registry
|
||||||
|
# uses: docker/login-action@v2
|
||||||
|
# with:
|
||||||
|
# registry: git.hofer.link
|
||||||
|
# username: ${{ secrets.GITEA_USERNAME }}
|
||||||
|
# password: ${{ secrets.GITEA_PASSWORD }}
|
||||||
|
#
|
||||||
|
# - name: Build and push another-image
|
||||||
|
# uses: docker/build-push-action@v4
|
||||||
|
# with:
|
||||||
|
# context: ./another-image
|
||||||
|
# push: true
|
||||||
|
# tags: git.hofer.link/philipp/ci-images:another-image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user