2024-06-06 16:52:08 +02:00
|
|
|
name: build container image
|
2024-05-30 23:04:58 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2024-05-30 23:23:56 +02:00
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
2024-05-30 23:04:58 +02:00
|
|
|
jobs:
|
2024-06-06 16:52:08 +02:00
|
|
|
release_tag:
|
2024-06-13 10:38:05 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2024-06-06 16:52:08 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Get latest release and create new release
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
# Get latest release.
|
|
|
|
latest_release=$(curl -s https://git.smail.koeln/api/v1/repos/homelab/docker-ownDynDNS-netcup/releases\?limit\=1 | jq -r '.[] | .tag_name')
|
|
|
|
|
|
|
|
# Cut release into year, month and counter.
|
2024-06-06 23:50:19 +02:00
|
|
|
year=$(echo $latest_release | awk -F '.' '//{print $1}')
|
|
|
|
month=$(echo $latest_release | awk -F '.' '//{print $2}')
|
2024-06-06 16:52:08 +02:00
|
|
|
counter=$(echo $latest_release | awk -F '.' '//{print $3}')
|
|
|
|
|
|
|
|
# increase the counter, if the release is from the same year and month
|
2024-06-06 23:52:29 +02:00
|
|
|
if [[ $(date +'%Y') == $year ]] && [[ $(date +'%m') == $month ]]; then
|
2024-06-06 16:52:08 +02:00
|
|
|
((counter++));
|
|
|
|
# else reset counter
|
|
|
|
else
|
|
|
|
counter=1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create
|
2024-06-06 23:56:44 +02:00
|
|
|
new_release=$(date +'%Y').$(date +'%m').$counter
|
2024-06-06 16:52:08 +02:00
|
|
|
echo "RELEASE=$new_release">> $GITHUB_ENV
|
2024-06-06 23:55:24 +02:00
|
|
|
echo "Release $new_release successfully set"
|
2024-06-06 16:52:08 +02:00
|
|
|
|
2024-05-30 23:04:58 +02:00
|
|
|
build:
|
2024-06-06 16:52:08 +02:00
|
|
|
needs: release_tag
|
2024-06-13 10:38:05 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2024-05-30 23:04:58 +02:00
|
|
|
steps:
|
2024-06-06 16:52:08 +02:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
|
|
|
|
2024-06-09 21:51:15 +02:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
2024-06-06 16:52:08 +02:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
2024-06-06 17:11:51 +02:00
|
|
|
with:
|
2024-06-09 21:51:15 +02:00
|
|
|
endpoint: tcp://docker:2376
|
2024-06-06 16:52:08 +02:00
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: ./docker-build
|
|
|
|
file: ./docker-build/Dockerfile
|
|
|
|
platforms: |
|
|
|
|
linux/arm/v7
|
|
|
|
linux/arm64
|
|
|
|
linux/amd64
|
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
${{ secrets.DOCKER_USER }}/docker-owndyndns-netcup:${{ env.VERSION }}
|
|
|
|
${{ secrets.DOCKER_USER }}/docker-owndyndns-netcup:latest
|