fix: broken dockerfile, add example deployment #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
environment: | |
name: docker | |
url: https://hub.docker.com/r/benfiola/external-dns-routeros-provider | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: install go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22.5" | |
- name: download versionctl | |
run: | | |
curl -fsSL -o /usr/local/bin/versionctl "https://github.com/benfiola/versionctl/releases/latest/download/versionctl-linux-amd64" | |
chmod +x /usr/local/bin/versionctl | |
- name: calculate facts | |
id: facts | |
run: | | |
version="$(versionctl next)" | |
tag="$(versionctl convert "${version}" git)" | |
image_base="docker.io/benfiola/external-dns-routeros-provider" | |
image_tag="$(versionctl convert "${version}" docker)" | |
image="${image_base}:${image_tag}" | |
latest_image="${image_base}:latest" | |
publish_latest="0" | |
if [ "${{github.ref}}" = "refs/heads/main" ]; then | |
publish_latest="1" | |
fi | |
echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
echo "tag=${tag}" >> "${GITHUB_OUTPUT}" | |
echo "image=${image}" >> "${GITHUB_OUTPUT}" | |
echo "latest_image=${latest_image}" >> "${GITHUB_OUTPUT}" | |
echo "publish_latest=${publish_latest}" >> "${GITHUB_OUTPUT}" | |
- name: test | |
run: | | |
go test ./internal/provider | |
- name: set version | |
run: | | |
echo "${{steps.facts.outputs.version}}" > internal/provider/version.txt | |
- name: prepare docker | |
run: | | |
docker buildx create --platform linux/arm64,linux/amd64 --use | |
docker login --username=benfiola --password "${{secrets.DOCKER_TOKEN}}" | |
- name: build image | |
run: | | |
docker buildx build --platform=linux/arm64,linux/amd64 --progress=plain . | |
- name: publish image | |
run: | | |
docker buildx build --platform=linux/arm64,linux/amd64 --progress=plain --push --tag="${{steps.facts.outputs.image}}" . | |
- name: publish latest image | |
if: "${{steps.facts.outputs.publish_latest == '1'}}" | |
run: | | |
docker buildx build --platform=linux/arm64,linux/amd64 --progress=plain --push --tag="${{steps.facts.outputs.latest_image}}" . | |
- name: tag | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{steps.facts.outputs.tag}}', | |
sha: context.sha | |
}) |