Skip to content

hangfire cron monitor #175

hangfire cron monitor

hangfire cron monitor #175

name: Scheduler
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
# SENTRY_LOG_LEVEL: "debug"
on:
push:
tags:
- 'v*.*.*'
branches:
- main
paths:
- 'src/NuGetTrends.Scheduler/**'
- 'src/NuGetTrends.Data/**'
- 'src/NuGet.Protocol.Catalog/**'
- 'src/Directory.Build.props'
- '**/scheduler-workflow.yml'
pull_request:
paths:
- 'src/NuGetTrends.Scheduler/**'
- 'src/NuGetTrends.Data/**'
- 'src/NuGet.Protocol.Catalog/**'
- 'src/Directory.Build.props'
- '**/scheduler-workflow.yml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Prepare Docker
id: docker-prep
run: |
DOCKER_IMAGE=nugettrends/nugettrends.scheduler
VERSION=noop
ENVIRONMENT=test
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
ENVIRONMENT=prod
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=environment::${ENVIRONMENT}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker values debug
run: |
echo ${{ steps.docker-prep.outputs.environment }}
echo ${{ steps.docker-prep.outputs.version }}
echo ${{ steps.docker-prep.outputs.tags }}
echo ${{ steps.docker-prep.outputs.created }}
- name: Build
run: dotnet build -c Release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
working-directory: src/NuGetTrends.Scheduler/
- name: Publish
run: dotnet publish -c Release -o publish --no-build
working-directory: src/NuGetTrends.Scheduler/
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: ./src/NuGetTrends.Scheduler
file: ./src/NuGetTrends.Scheduler/Dockerfile
build-args: |
ENVIRONMENT=${{ steps.docker-prep.outputs.environment }}
VERSION=${{ steps.docker-prep.outputs.version }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-prep.outputs.tags }}
labels: |
org.opencontainers.image.created=${{ steps.docker-prep.outputs.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.docker-prep.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}