Skip to content

Docker Build All

Docker Build All #51

name: Docker Build All
on:
schedule:
- cron: "0 0 * * 2" # every tuesday at midnight
workflow_dispatch:
jobs:
list-branches:
name: Get all branch names
runs-on: ubuntu-latest
outputs:
branch-names: ${{ steps.get-branch-names.outputs.branch-names }}
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Get branch names
id: get-branch-names
run: |
git fetch --all --prune --tags
branches=$(git branch -r --format='%(refname:short)' \
| sed 's#^[^/]*/##' \
| grep -v -x 'origin' \
| grep -v -x 'HEAD' \
| grep -v -x 'main' \
| sort -u)
if [ -z "$branches" ]; then
echo "branch-names=[]" >> $GITHUB_OUTPUT
else
json=$(printf '%s\n' "$branches" | jq -R -s -c 'split("\n")[:-1]')
echo "branch-names=$json" >> $GITHUB_OUTPUT
fi
build-docker-image:
name: ghcr.io/biaw/${{ matrix.branch }}
runs-on: ubuntu-latest
needs: list-branches
strategy:
fail-fast: false
matrix:
branch: ${{ fromJson(needs.list-branches.outputs.branch-names) }}
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
ref: ${{ matrix.branch }}
- name: Login to ghcr.io
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4
with:
context: .
push: true
tags: ghcr.io/biaw/${{ matrix.branch }}:latest