Skip to content

Add missing license file #10

Add missing license file

Add missing license file #10

Workflow file for this run

name: Docker Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
docker-build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- '5000:5000'
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
IMG_NAME: sagemcom_fast_exporter
steps:
- name: enable experimental mode
run: |
mkdir -p ~/.docker
echo '{"experimental": "enabled"}' > ~/.docker/config.json
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.1
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
- name: determine if this is a tag
run: |
if (git describe --abbrev=0 --exact-match &>/dev/null); then
tag=$(git describe --abbrev=0 --exact-match)
echo "is_tag=true" >> $GITHUB_ENV
echo "git_tag=$tag" >> $GITHUB_ENV
# splits the major version from $tag - assumes it's a 3-part semver
echo "major_version=${tag%%\.*}" >> $GITHUB_ENV
fi
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter'
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: hairyhenderson
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Build & Push (non-main branch)
run: |
set -ex
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=localhost:5000/${IMG_NAME} BUILDX_ACTION=--push
docker buildx imagetools create --dry-run -t localhost:5000/${IMG_NAME}:dev localhost:5000/${IMG_NAME}:latest
docker buildx imagetools create --dry-run -t localhost:5000/${IMG_NAME}:dev-alpine localhost:5000/${IMG_NAME}:alpine
if: github.repository != 'hairyhenderson/sagemcom_fast_exporter' || github.ref != 'refs/heads/main'
- name: Build & Push (main/tags)
run: |
src_repo=hairyhenderson/${IMG_NAME}
set -x
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${src_repo} BUILDX_ACTION=--push
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Push (tagged release)
run: |
src_repo=hairyhenderson/${IMG_NAME}
set -x
repo=$src_repo
docker buildx imagetools create -t ${repo}:${git_tag} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${src_repo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${src_repo}:alpine
repo=ghcr.io/hairyhenderson/${IMG_NAME}
docker buildx imagetools create -t ${repo}:${git_tag} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${src_repo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${src_repo}:alpine
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && env.is_tag == 'true'