Skip to content

inital commit

inital commit #1

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 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 branch)
run: |
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/${IMG_NAME} BUILDX_ACTION=--push
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && github.ref == 'refs/heads/main'
- name: Build & Push (tagged release)
run: |
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/${IMG_NAME} BUILDX_ACTION=--push
set -x
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${git_tag} hairyhenderson/${IMG_NAME}:latest
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${major_version} hairyhenderson/${IMG_NAME}:latest
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${git_tag}-alpine hairyhenderson/${IMG_NAME}:alpine
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${major_version}-alpine hairyhenderson/${IMG_NAME}:alpine
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && env.is_tag == 'true'