feat: change forgejo actions

This commit is contained in:
sujiba 2024-06-06 16:52:08 +02:00
parent 74dbef2506
commit 68013cc2e7
3 changed files with 64 additions and 58 deletions

View file

@ -1,4 +1,4 @@
name: Build and push dyndns-netcup name: build container image
on: on:
push: push:
@ -6,40 +6,68 @@ on:
- main - main
jobs: jobs:
build:
release_tag:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- - name: Checkout
name: Checkout uses: actions/checkout@v4
uses: actions/checkout@v4
- - name: Install jq
name: Login to Docker Hub run: apt-get update && apt-get upgrade && apt-get install -y jq
uses: docker/login-action@v3
with: - name: Get latest release and create new release
username: ${{ secrets.DOCKER_USER }} shell: bash
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} run: |
- # Get latest release.
name: Set up variables latest_release=$(curl -s https://git.smail.koeln/api/v1/repos/homelab/docker-ownDynDNS-netcup/releases\?limit\=1 | jq -r '.[] | .tag_name')
run: |
VER=$(cat ./docker-build/VERSION) # Cut release into year, month and counter.
echo "VERSION=$VER" >> $GITHUB_ENV year=$(echo $latest_release | awk -F '.' '//{print $1}')
- month=$(echo $latest_release | awk -F '.' '//{print $2}')
name: Set up QEMU counter=$(echo $latest_release | awk -F '.' '//{print $3}')
uses: docker/setup-qemu-action@v3
- # increase the counter, if the release is from the same year and month
name: Set up Docker Buildx if [ $(date +'%Y') -eq year ] && [ $(date +'%m') -eq month ]; then
uses: docker/setup-buildx-action@v3 ((counter++));
- # else reset counter
name: Build and push else
uses: docker/build-push-action@v5 counter=1;
with: fi
context: ./docker-build
file: ./docker-build/Dockerfile # Create
platforms: | new_release=$(date +'%Y').$(date +'mY').$counter
linux/arm/v7 echo "RELEASE=$new_release">> $GITHUB_ENV
linux/arm64
linux/amd64 build:
push: true needs: release_tag
tags: | runs-on: ubuntu-latest
${{ secrets.DOCKER_USER }}/docker-owndyndns-netcup:${{ env.VERSION }} steps:
${{ secrets.DOCKER_USER }}/docker-owndyndns-netcup:latest - 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 }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- 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

View file

@ -1,20 +0,0 @@
# Build it yourself
https://docs.docker.com/buildx/working-with-buildx/#work-with-builder-instances
```
# This creates a new builder instance with a single node based on your current configuration.
docker buildx create
# To list all available builders, use
docker buildx ls
# To switch between different builders, use
docker buildx use <name>
# After creating a new instance, you can delete it with
docker buildx rm <name>
```
Build it as a multi-platform image:
```
chmod +x build_and_push.sh
./build_and_push.sh
```

View file

@ -1,2 +0,0 @@
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t sujiba/docker-owndyndns-netcup:`cat VERSION` --push .
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t sujiba/docker-owndyndns-netcup:latest --push .