SHA256
58 lines
1.8 KiB
YAML
58 lines
1.8 KiB
YAML
name: Dynamic Build and Deploy Hardened Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
schedule:
|
|
- cron: '0 0 * * 5'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
strategy:
|
|
matrix:
|
|
runner: [linux-amd64, linux-arm64]
|
|
runs-on: ${{ matrix.runner }}
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to DHI Registry
|
|
run: |
|
|
echo "${{ secrets.DHI_PASSWORD }}" | docker login dhi.io -u "${{ secrets.DHI_USERNAME }}" --password-stdin
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
run: |
|
|
echo "${{ secrets.GITEA_REGISTRY_TOKEN }}" | docker login git.chillcog.com -u "${{ github.repository_owner }}" --password-stdin
|
|
|
|
- name: Detect and Build Images
|
|
env:
|
|
REPO_OWNER: ${{ github.repository_owner }}
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
run: |
|
|
REGISTRY_HOST="git.chillcog.com"
|
|
IF_OWNER="${REPO_OWNER:-chillcog}"
|
|
OWNER_LOWER=$(echo "$IF_OWNER" | tr '[:upper:]' '[:lower:]')
|
|
|
|
FILES_TO_BUILD=$(find . -maxdepth 1 \( -name "*.yml" -o -name "*.yaml" \))
|
|
|
|
for file in $FILES_TO_BUILD; do
|
|
file=$(echo "$file" | sed 's|^\./||')
|
|
|
|
[ -f "$file" ] || continue
|
|
|
|
filename=$(basename -- "$file")
|
|
image_base="${filename%.*}"
|
|
image_name=$(echo "$image_base" | tr '[:upper:]' '[:lower:]')
|
|
|
|
TARGET_TAG="${REGISTRY_HOST}/${OWNER_LOWER}/${image_name}:latest"
|
|
|
|
echo "---------------------------------------------------"
|
|
echo "Processing: $file -> Target: $TARGET_TAG"
|
|
echo "---------------------------------------------------"
|
|
|
|
docker build -f "$file" -t "$TARGET_TAG" .
|
|
docker push "$TARGET_TAG"
|
|
done |