Skip to content

Docker Nightly

Docker Nightly #42

name: Docker Nightly
on:
push:
paths-ignore:
- "*.md"
- ".github/**"
- "!.github/workflows/docker-nightly.yml"
branches:
- main
workflow_dispatch:
jobs:
determine-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set matrix
id: set-matrix
run: |
APPS=("web-app" "website" "email")
CHANGED=()
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
CHANGED=("${APPS[@]}")
else
for app in "${APPS[@]}"; do
folder="apps/${app}"
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^${folder}/"; then
CHANGED+=("${app}")
fi
done
fi
if [ ${#CHANGED[@]} -gt 0 ]; then
echo "matrix=$(printf '%s\n' "${CHANGED[@]}" | jq -R . | jq -s . | tr -d '[:space:]')" >> $GITHUB_OUTPUT
else
echo "matrix=[]" >> $GITHUB_OUTPUT
fi
- name: Result
run: |
echo "${{ steps.set-matrix.outputs.matrix }}"
build:
needs: determine-changes
if: ${{ needs.determine-changes.outputs.matrix != '[]' }}
runs-on: ubuntu-latest
strategy:
matrix:
app: ${{ fromJson(needs.determine-changes.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set APP in env
run: |
echo "APP_NAME=${{ matrix.app }}" >> $GITHUB_ENV
echo "APP_VERSION=nightly" >> $GITHUB_ENV
- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.package }}
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ env.APP_NAME }}/Dockerfile
push: true
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
tags: ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:${{ env.APP_VERSION }}