blob: 6781927600881497b836cdf58c45a0af8a2781b6 [file] [log] [blame]
name: Docker Utility Builds
on:
push:
branches:
- main
paths:
- '.github/docker/utility/**'
pull_request:
branches:
- main
paths:
- '.github/docker/utility/**'
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
packages: write
jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
directory:
- maven-node
- osee-postgres
steps:
- name: Calculate Fetch Depth
env:
COMMITS: ${{ toJson(github.event.commits) }}
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
COUNT=$(( $(echo "$COMMITS" | jq length) + 1 ))
else
COUNT=1
fi
echo "fetch_depth=$COUNT" | tee -a "$GITHUB_ENV"
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.fetch_depth }}
- name: Check For Changes In ${{ matrix.directory }}
id: check_changes
uses: tj-actions/changed-files@v44
with:
files: |
.github/docker/utility/${{ matrix.directory }}/**/*
- name: Set Up Docker Buildx
if: steps.check_changes.outputs.any_modified == 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: steps.check_changes.outputs.any_modified == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Current Timestamp
if: steps.check_changes.outputs.any_modified == 'true'
id: date
run: echo "timestamp=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Build And Push Docker Image
if: steps.check_changes.outputs.any_modified == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: .github/docker/utility/${{ matrix.directory }}/Dockerfile
build-args: |
IMAGE_DIRECTORY=.github/docker/utility/${{ matrix.directory }}
push: ${{ github.event_name == 'push' }}
tags: |
ghcr.io/${{ github.repository }}/${{ matrix.directory }}:${{ github.sha }}
ghcr.io/${{ github.repository }}/${{ matrix.directory }}:${{ steps.date.outputs.timestamp }}
ghcr.io/${{ github.repository }}/${{ matrix.directory }}:latest