try ci
This commit is contained in:
47
.gitea/workflows/docker-build.yml
Normal file
47
.gitea/workflows/docker-build.yml
Normal file
@ -0,0 +1,47 @@
|
||||
name: Build and Push Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '*/Dockerfile'
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Determine which image to build
|
||||
- name: Set image details
|
||||
id: image_details
|
||||
run: |
|
||||
# Extract the directory of the changed Dockerfile
|
||||
CHANGED_FILE="${{ github.event.commits[0].modified[0] }}"
|
||||
if [[ $CHANGED_FILE == */Dockerfile ]]; then
|
||||
IMAGE_PATH=$(dirname "$CHANGED_FILE")
|
||||
else
|
||||
IMAGE_PATH="rust-latest" # Default
|
||||
fi
|
||||
|
||||
# Set outputs
|
||||
echo "image_path=$IMAGE_PATH" >> $GITHUB_OUTPUT
|
||||
echo "image_name=$(basename $IMAGE_PATH)" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "Building image from directory: $IMAGE_PATH"
|
||||
echo "Image name: $(basename $IMAGE_PATH)"
|
||||
|
||||
- name: Login to Gitea Docker Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: git.hofer.link
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./${{ steps.image_details.outputs.image_path }}
|
||||
push: true
|
||||
tags: git.hofer.link/philipp/ci-images:${{ steps.image_details.outputs.image_name }}
|
||||
|
Reference in New Issue
Block a user