Skip to content

Commit 754574a

Browse files
committed
feat. Publish docker container to github registry
1 parent cce6842 commit 754574a

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@ on:
88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
1114
steps:
1215
- uses: actions/checkout@v4
13-
- name: Setup .NET
14-
uses: actions/setup-dotnet@v4
16+
- name: Log in to GitHub Container Registry
17+
uses: docker/login-action@v3
1518
with:
16-
dotnet-version: 8.0.x
17-
- name: Publish
18-
run: dotnet publish dotpaste/dotpaste.csproj -c Release -o build
19-
- name: Upload to server
20-
uses: ErSoul/scp_uploader@v1.0
21-
with:
22-
host: ${{vars.SSH_HOST}}
23-
username: ${{secrets.SSH_USER}}
24-
key: ${{secrets.SSH_KEY}}
25-
source: ./build/*
26-
target: /srv/dotpaste
27-
after: systemctl --user restart dotpaste
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Build and Publish
23+
run: |
24+
dotnet publish dotpaste --os linux --arch x64 /t:PublishContainer -p ContainerTag=$(git describe --tags --always)

dotpaste/dotpaste.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77

88
<PropertyGroup>
99
<ContainerBaseImage>mcr.microsoft.com/dotnet/aspnet:8.0-alpine-composite</ContainerBaseImage>
10+
<ContainerRegistry>ghcr.io</ContainerRegistry>
11+
<ContainerRepository>ErSoul/dotpaste</ContainerRepository>
1012
</PropertyGroup>
1113
</Project>

0 commit comments

Comments
 (0)