Skip to content

Commit

Permalink
Adding docker image build for prometheus pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
arlake228 committed Aug 28, 2023
1 parent a63ebb1 commit c96c860
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/publish_docker_prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Logstash Docker Images

# This action builds Docker images of logstash then
# pushes result to GitHub Container Registry.

on:
push:
branches: [ '*' ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ 'main' ]

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_BASE: ${{ github.repository }}
BUILD_DIR: perfsonar-logstash/perfsonar-logstash
IMAGE_SUBNAME: prometheus

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https:/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https:/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}-${{ env.IMAGE_SUBNAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# Build and push Docker image with Buildx (don't push on PR)
# https:/docker/build-push-action
- name: Build and push Docker images
id: build-and-push
uses: docker/build-push-action@v3
with:
context: ${{ env.BUILD_DIR }}
file: ${{ env.BUILD_DIR }}/docker/Dockerfile-${{ env.IMAGE_SUBNAME }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit c96c860

Please sign in to comment.