Skip to content

Commit 680172e

Browse files
committed
Support versioned Docker tags from GitHub Releases
1 parent 540b81e commit 680172e

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/build-and-deploy.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ on:
77
pull_request:
88
branches:
99
- master
10+
release:
11+
types: [published]
1012
workflow_dispatch:
1113

1214
env:
1315
REGISTRY: ghcr.io
1416
IMAGE_NAME: ${{ github.repository }}
1517

1618
jobs:
17-
build-test-deploy:
19+
test:
1820
runs-on: ubuntu-latest
19-
permissions:
20-
contents: read
21-
packages: write
22-
2321
steps:
2422
- name: Checkout code
2523
uses: actions/checkout@v4
@@ -35,34 +33,49 @@ jobs:
3533
- name: Run Tests
3634
run: dotnet test --configuration Release
3735

36+
docker:
37+
needs: test
38+
if: github.event_name != 'pull_request'
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: read
42+
packages: write
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Setup .NET 9
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: '9.0.x'
52+
3853
- name: Publish
3954
run: dotnet publish Muxarr.Web/Muxarr.Web.csproj -c Release -o Muxarr.Web/publish
4055

4156
- name: Set up Docker Buildx
42-
if: github.event_name != 'pull_request'
4357
uses: docker/setup-buildx-action@v3
4458

4559
- name: Log in to Container Registry
46-
if: github.event_name != 'pull_request'
4760
uses: docker/login-action@v3
4861
with:
4962
registry: ${{ env.REGISTRY }}
5063
username: ${{ github.actor }}
5164
password: ${{ secrets.GITHUB_TOKEN }}
5265

5366
- name: Extract metadata
54-
if: github.event_name != 'pull_request'
5567
id: meta
5668
uses: docker/metadata-action@v5
5769
with:
5870
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5971
tags: |
60-
type=raw,value=latest
61-
type=raw,value=${{ github.run_number }}
72+
type=raw,value=latest,enable={{is_default_branch}}
73+
type=semver,pattern={{version}}
74+
type=semver,pattern={{major}}.{{minor}}
75+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
6276
type=sha
6377
6478
- name: Build and push Docker image
65-
if: github.event_name != 'pull_request'
6679
uses: docker/build-push-action@v6
6780
with:
6881
context: Muxarr.Web

0 commit comments

Comments
 (0)