Skip to content

Create and publish artifacts #4

Create and publish artifacts

Create and publish artifacts #4

Workflow file for this run

name: Create and publish artifacts
on:
push:
branches: main
schedule:
- cron: "2 02 4 * *"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push-image:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
releases-matrix:
permissions:
contents: write
name: Release Go Binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Build
run: go build -ldflags="-s -w" -trimpath -o datadis_exporter main.go
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- name: Compress
run: zip datadis_exporter-${{ matrix.goos }}-${{ matrix.goarch }}.zip datadis_exporter
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: datadis_exporter-${{ matrix.goos }}-${{ matrix.goarch }}.zip
tag_name: latest