Compare commits
8 Commits
0d14d50a9f
...
renovate/c
| Author | SHA1 | Date | |
|---|---|---|---|
| 06028eb5d6 | |||
| 050d309957 | |||
| ad20ad46b0 | |||
| ccf4f5dbbb | |||
| e53827adf0 | |||
| ad0932f4aa | |||
| fff36bf807 | |||
| 1c725993f5 |
@@ -9,6 +9,27 @@ env:
|
||||
DOCKER_REGISTRY: gitea.t000-n.de
|
||||
|
||||
jobs:
|
||||
check-changes:
|
||||
name: Check changes
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
changes: ${{ steps.filter.outputs.code }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Get changes
|
||||
id: filter
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
filters: |
|
||||
code:
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- '**/*.go'
|
||||
- 'config.example.yaml'
|
||||
- 'Dockerfile'
|
||||
- 'Makefile'
|
||||
|
||||
test:
|
||||
name: test
|
||||
runs-on: ubuntu-latest
|
||||
@@ -44,18 +65,58 @@ jobs:
|
||||
|
||||
build_and_push:
|
||||
name: Build and push
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, arm64]
|
||||
needs:
|
||||
- test
|
||||
- check-changes
|
||||
if: ${{ needs.check-changes.outputs.code == 'true' }}
|
||||
runs-on:
|
||||
- ubuntu-latest
|
||||
- linux_${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
- name: Get Metadata
|
||||
id: meta
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
push: true
|
||||
provenance: false
|
||||
build-args: GOARCH=${{ matrix.arch }}
|
||||
tags: |
|
||||
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-${{ matrix.arch }}
|
||||
|
||||
create_manifest:
|
||||
name: Create manifest
|
||||
needs:
|
||||
- build_and_push
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Get Metadata
|
||||
id: meta
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@v2
|
||||
@@ -64,21 +125,10 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Get Metadata
|
||||
id: meta
|
||||
- name: Create manifest
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
docker manifest create ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest \
|
||||
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64 \
|
||||
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-arm64
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
||||
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest
|
||||
docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest
|
||||
|
||||
15
Dockerfile
15
Dockerfile
@@ -1,13 +1,14 @@
|
||||
FROM golang:1.23-alpine
|
||||
FROM golang:1.23-alpine as build
|
||||
|
||||
ARG GOARCH=amd64
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} \
|
||||
go build -trimpath -ldflags="-s -w" -o main .
|
||||
|
||||
RUN go build -o main .
|
||||
|
||||
CMD ["./main"]
|
||||
FROM gcr.io/distroless/static-debian12
|
||||
COPY --from=build /app/main /
|
||||
CMD ["/main"]
|
||||
|
||||
@@ -38,6 +38,7 @@ domains:
|
||||
- www
|
||||
check_interval: 0 0 0/6 * * * *
|
||||
mode: Scheduled
|
||||
log_level: info
|
||||
```
|
||||
|
||||
The config file is expected to be in the same directory as the binary and called `config.yaml`. For the OCR image, the root directory is `/app`.
|
||||
|
||||
@@ -21,3 +21,4 @@ domains:
|
||||
- www
|
||||
check_interval: 0 0 0/6 * * * *
|
||||
mode: Scheduled
|
||||
log_level: info
|
||||
|
||||
@@ -3,6 +3,7 @@ package realDynDns
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"realdnydns/pkg/config"
|
||||
@@ -70,10 +71,17 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var numberUpdated int
|
||||
var wg sync.WaitGroup
|
||||
|
||||
numberUpdatedChannel := make(chan int)
|
||||
|
||||
for _, domain := range c.domains {
|
||||
for _, subdomain := range domain.Subdomains {
|
||||
wg.Add(1)
|
||||
|
||||
go func(domain config.DomainConfig, subdomain string) {
|
||||
defer wg.Done()
|
||||
|
||||
c.logger.Info("Checking record",
|
||||
slog.String("tld", domain.TLD),
|
||||
slog.String("subdomain", subdomain),
|
||||
@@ -85,7 +93,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
|
||||
slog.String("tld", domain.TLD),
|
||||
slog.String("subdomain", subdomain),
|
||||
)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
if currentRecord.IP != externalIp.String() {
|
||||
@@ -104,7 +112,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
|
||||
c.logger.Warn("Failed to send notification",
|
||||
slog.String("error", err.Error()),
|
||||
)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
c.logger.Info("Updating record",
|
||||
@@ -120,11 +128,23 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
|
||||
slog.String("tld", domain.TLD),
|
||||
slog.String("subdomain", subdomain),
|
||||
)
|
||||
continue
|
||||
return
|
||||
}
|
||||
numberUpdated++
|
||||
|
||||
numberUpdatedChannel <- 1
|
||||
}
|
||||
}(domain, subdomain)
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(numberUpdatedChannel)
|
||||
}()
|
||||
|
||||
numberUpdated := 0
|
||||
for v := range numberUpdatedChannel {
|
||||
numberUpdated += v
|
||||
}
|
||||
|
||||
c.logger.Info("Run completed", slog.Int("number_of_changes", numberUpdated))
|
||||
|
||||
3
renovate.json
Normal file
3
renovate.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||
}
|
||||
Reference in New Issue
Block a user