Skip to content

buildall-bin-from-src push script #153

buildall-bin-from-src push script

buildall-bin-from-src push script #153

# This script builds runtime images created by build-indimail-src.yml
# the images are common for both indimail and indimail-mta
# the images have all packages required by indimail, indimail-mta installed and compiled
# using these images instead of the base images reduces build times
name: buildall-bin-from-src push script
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
distro_list:
# Friendly description to be shown in the UI instead of 'name'
Distro List: 'distro list'
# Input has to be provided for the workflow to run
required: false
jobs:
build_and_push:
name: build and push source images
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: login
run: |
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io --username "${{ github.repository_owner }}" --password-stdin
echo "${{ secrets.DOCKER_PAT }}" | docker login docker.io --username cprogrammer --password-stdin
- name: build
run: |
set +e
echo "Input=${{ github.event.inputs.distro_list }}"
if [ -z "${{ github.event.inputs.distro_list }}" ] ; then
package_list="indimail indimail-mta"
distros="alpine archlinux fedora stream8 stream9 ubi8 ubi9 gentoo"
else
echo "${{ github.event.inputs.distro_list }}" | grep ":" > /dev/null
if [ $? -eq 0 ] ; then
package_list=$(echo "${{ github.event.inputs.distro_list }}" | cut -d: -f2)
distros=$(echo "${{ github.event.inputs.distro_list }}" | cut -d: -f1)
else
package_list="indimail indimail-mta"
distros="${{ github.event.inputs.distro_list }}"
fi
fi
flag=""
for i in $distros
do
for j in $package_list
do
echo "Using indimail-src/$i.$j.bin for build"
cp indimail-src/$i.$j.bin Dockerfile
if [ -d indimail-mta/$i -o -d indimail/$i ] ; then
tag="$i".s
else
tag="$i"
fi
docker build --tag "ghcr.io/${{ github.repository_owner }}/$j:$tag" . > $i.$j.log 2>&1
if [ $? -eq 0 ] ; then
echo "docker push ghcr.io/${{ github.repository_owner }}/$j:$tag"
docker push "ghcr.io/${{ github.repository_owner }}/$j:$tag"
docker image tag "ghcr.io/${{ github.repository_owner }}/$j:$tag" docker.io/cprogrammer/$j:$tag
echo "docker push docker.io/cprogrammer/$j:$tag"
docker push docker.io/cprogrammer/$j:$tag
else
cat $i.$j.log
flag="$flag $j:$i"
fi
/bin/rm -f Dockerfile
gzip $i.$j.log
done
done
if [ -n "$flag" ] ; then
echo "docker build failed for $flag"
exit 1
fi
- uses: actions/upload-artifact@v2
with:
name: buildall-bin-from-src-logs
path: '*.log.gz'