-
Notifications
You must be signed in to change notification settings - Fork 5
46 lines (39 loc) · 1.2 KB
/
dockerhub.yml
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
name: Build and Push .NET 8 Docker Image to DockerHub
on:
push:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: servicestack
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
env:
DOCKER_REPO: servicestack/${{ github.event.repository.name }}
run: |
# Determine version tag
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${{ github.sha }}
fi
# Build and push using dotnet publish
dotnet publish --os linux --arch x64 -c Release \
-p:PublishProfile=DefaultContainer \
-p:ContainerRepository=$DOCKER_REPO \
-p:ContainerImageTags="latest"
# Push the image
docker push $DOCKER_REPO:latest