diff --git a/.gitea/workflows/buiildpublish.yaml b/.gitea/workflows/buiildpublish.yaml new file mode 100644 index 0000000..fdee398 --- /dev/null +++ b/.gitea/workflows/buiildpublish.yaml @@ -0,0 +1,18 @@ +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Build the project + run: | + ./build.sh + - name: Publish + run: | + ./publish.sh + + diff --git a/Dockerfile b/Dockerfile.debian-curl similarity index 100% rename from Dockerfile rename to Dockerfile.debian-curl diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cd07d20 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +# iterate through the docker files in format Dockerfile.IMAGE_NAME +for dockerfile in Dockerfile.* +do + # get the image name from the dockerfile + image_name="${dockerfile//Dockerfile./}" + # build the gitea.jde.nz/public/bb64:debian-curl docker image + docker build -t "$image_name:latest" -f "$dockerfile" . +done + + diff --git a/publish.sh b/publish.sh index 9350728..88159c6 100755 --- a/publish.sh +++ b/publish.sh @@ -1,8 +1,24 @@ #!/bin/bash -# build the gitea.jde.nz/public/bb64:debian-curl docker image -docker build -t gitea.jde.nz/public/debian-curl:latest -f Dockerfile . +set -euo pipefail + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# get date/time in local timezone, format YYYY.MMDD.HHMMSS +DATETIME=$(date +%Y.%m%d.%H%M%S) + +"${SCRIPTDIR}/build.sh" + +# iterate through the docker files in format Dockerfile.IMAGE_NAME +for dockerfile in Dockerfile.* +do + # get the image name from the dockerfile + image_name="${dockerfile//Dockerfile./}" + # tag the image with the latest tag + docker tag "$image_name:latest" "gitea.jde.nz/public/$image_name:latest" + docker tag "$image_name:latest" "gitea.jde.nz/public/$image_name:$DATETIME" + # push the image to the local docker registry + docker push -a "gitea.jde.nz/public/$image_name" +done -# push the gitea.jde.nz/public/bb64:debian-curl docker image to the gitea.jde.nz registry -docker push gitea.jde.nz/public/debian-curl:latest