44 lines
1.7 KiB
YAML
44 lines
1.7 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
apache: ${{ steps.filter.outputs.apache }}
|
|
php: ${{ steps.filter.outputs.php }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Detect changed folders
|
|
id: filter
|
|
run: |
|
|
echo "apache=$(git diff --name-only HEAD~1 HEAD | grep '^apache/' | wc -l | grep -q '^0$' && echo false || echo true)" >> $GITHUB_OUTPUT
|
|
echo "php=$(git diff --name-only HEAD~1 HEAD | grep '^php/' | wc -l | grep -q '^0$' && echo false || echo true)" >> $GITHUB_OUTPUT
|
|
|
|
build-apache:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.apache == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
|
- run: docker build -t ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/apache:latest -f ./apache/Dockerfile .
|
|
- run: docker push ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/apache:latest
|
|
|
|
build-php:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.php == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
|
- run: docker build -t ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/php:latest -f ./php/Dockerfile .
|
|
- run: docker push ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/php:latest
|