try ci
This commit is contained in:
parent
533f21906f
commit
334b2fffc7
57
.gitea/workflows/docker-build.yml
Normal file
57
.gitea/workflows/docker-build.yml
Normal file
@ -0,0 +1,57 @@
|
||||
name: Build and Push Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths:
|
||||
- '*/Dockerfile'
|
||||
- '.gitea/workflows/docker-build.yml'
|
||||
|
||||
jobs:
|
||||
detect-changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect changed directories
|
||||
id: set-matrix
|
||||
run: |
|
||||
CHANGED_DIRS=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'Dockerfile' | xargs -L1 dirname | sort | uniq | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
||||
echo "matrix=${CHANGED_DIRS}" >> $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
needs: detect-changes
|
||||
if: ${{ needs.detect-changes.outputs.matrix != '[]' && needs.detect-changes.outputs.matrix != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
image_dir: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- 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: Extract image name from directory
|
||||
id: image-name
|
||||
run: |
|
||||
IMAGE_NAME=$(basename ${{ matrix.image_dir }})
|
||||
echo "name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ${{ matrix.image_dir }}
|
||||
push: true
|
||||
tags: git.hofer.link/philipp/ci-images:${{ steps.image-name.outputs.name }}
|
||||
|
@ -5,7 +5,7 @@
|
||||
# 2. Tag the image: `docker tag <id> git.hofer.link/philipp/ci-images:rust-latest`
|
||||
# 3. Push the image: `docker push git.hofer.link/philipp/ci-images:rust-latest`
|
||||
|
||||
FROM rust:1.85.1
|
||||
FROM rust:1.86
|
||||
|
||||
RUN apt-get update && apt-get install -y sqlite3
|
||||
|
Loading…
x
Reference in New Issue
Block a user