-
Notifications
You must be signed in to change notification settings - Fork 45
92 lines (83 loc) · 3 KB
/
Copy pathscheduler-workflow.yml
File metadata and controls
92 lines (83 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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/NuGetTrends.Data.Tests/**'
- 'src/NuGet.Protocol.Catalog/**'
- 'src/Directory.Build.props'
- '**/scheduler-workflow.yml'
pull_request:
paths:
- 'src/NuGetTrends.Scheduler/**'
- 'src/NuGetTrends.Data/**'
- 'src/NuGetTrends.Data.Tests/**'
- '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@v4
with:
dotnet-version: '10.0.x'
- name: Build
run: dotnet build -c Release -p:SourceRevisionId=${GITHUB_SHA::8}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
working-directory: src/NuGetTrends.Scheduler/
- name: Test
run: dotnet test -c Release -p:SentryUploadSymbols=false
working-directory: src/NuGetTrends.Data.Tests/
- name: Compute image tags
id: tags
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
MINOR="${VERSION%.*}"
MAJOR="${MINOR%.*}"
echo "tags=${VERSION};${MINOR};${MAJOR};latest" >> "$GITHUB_OUTPUT"
else
echo "tags=main;sha-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
fi
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create container image
run: >
dotnet publish --no-build -c Release
/t:PublishContainer
${{ github.event_name == 'pull_request' && '-p:ContainerArchiveOutputPath=./container.tar.gz' || '-p:ContainerRegistry=docker.io' }}
env:
ContainerImageTags: ${{ steps.tags.outputs.tags }}
working-directory: src/NuGetTrends.Scheduler/
- name: Smoke test container
if: github.event_name == 'pull_request'
working-directory: src/NuGetTrends.Scheduler/
run: |
docker load -i container.tar.gz
image="nugettrends/nugettrends.scheduler:sha-${GITHUB_SHA::8}"
docker image inspect "$image" > /dev/null
entrypoint=$(docker inspect --format='{{json .Config.Entrypoint}}' "$image")
echo "Container entrypoint: $entrypoint"
if ! echo "$entrypoint" | grep -q '/App/NuGetTrends.Scheduler.dll'; then
echo "::error::Container entrypoint does not point to /App/NuGetTrends.Scheduler.dll"
exit 1
fi
output=$(timeout 10s docker run --rm --pull=never "$image" 2>&1 || true)
echo "$output"