-
-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (70 loc) · 2.91 KB
/
main.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
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
name: Build
on:
push:
branches:
- main
- renovate/*
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
publish:
description: Publish
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4
with:
dotnet-version: '9.0.x'
- name: Build project
run: |
dotnet publish ./HomeAutomation.Web/HomeAutomation.Web.csproj --self-contained true --runtime linux-x64 --output ./output/HomeAutomation-Web-linux-x64
dotnet publish ./HomeAutomation.Web/HomeAutomation.Web.csproj --self-contained true --runtime win-x64 --output ./output/HomeAutomation-Web-win-x64
- name: Build Docker images
run: |
for appname in HomeAutomation.Web; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Building $appname docker amd64"
docker build -t $app:amd64 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim
done
- name: Upload Build Artifacts
if: github.ref == 'refs/heads/main' || github.event.inputs.publish == 'true'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: HomeAutomation-Web-linux-x64
path: ./output/HomeAutomation-Web-linux-x64
- name: Upload Build Artifacts (win-x64)
if: github.ref == 'refs/heads/main' || github.event.inputs.publish == 'true'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: HomeAutomation-Web-win-x64
path: ./output/HomeAutomation-Web-win-x64
- name: Push Docker images
if: github.ref == 'refs/heads/main' || github.event.inputs.publish == 'true'
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
for appname in HomeAutomation.Web; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Deploying $appname"
for arch in amd64; do
docker tag $app:$arch $DOCKER_USERNAME/$app:latest-$arch
done
for ver in latest; do
echo "Deploying version $ver"
for arch in amd64; do
echo "Pushing docker tag $ver-arch"
docker push $DOCKER_USERNAME/$app:$ver-$arch
done
docker manifest create $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64 --os linux --arch amd64
docker manifest push $DOCKER_USERNAME/$app:$ver
done
done
env:
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled