Skip to content

Added Makefile, Dockerfile and other CI improvements #5

Added Makefile, Dockerfile and other CI improvements

Added Makefile, Dockerfile and other CI improvements #5

Workflow file for this run

name: Release prom-exporter
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.21.x
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare
id: prepare
if: ${{ !env.ACT }}
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build image
id: build
if: ${{ env.ACT }}
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: prom-exporter:test
- name: Test Execution
if: ${{ env.ACT }}
run: |
timeout 10s docker run --rm prom-exporter:test \
-listen-address ":9201" \
-service-name "test" -service-uri "test" -service-port "5066" -service-metrics-path "stats" || code=$?
if [[ $code -ne 124 ]]; then
echo "Exporter stopped with ${code}. It was expected to run forever."
exit 1;
fi
- name: Release
if: ${{ !env.ACT }}
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --timeout=5m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}
- name: Build and push
if: ${{ !env.ACT }}
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.release
push: true
tags: mgsousa/prom-exporter:latest,mgsousa/prom-exporter:${{ steps.prepare.outputs.tag_name }}