Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for GitVersion
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.1.1
Expand All @@ -41,7 +41,6 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
needs: version

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -80,19 +79,48 @@ jobs:
- name: Run tests
run: dotnet run --project test/ServiceBusEmulatorExplorer.Tests/ServiceBusEmulatorExplorer.Tests.csproj --configuration Release

docker:
# Build Docker image on PRs (no push) to verify it compiles
docker-build:
runs-on: ubuntu-latest
needs: [version, build-and-test]
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image (no push)
uses: docker/build-push-action@v6
with:
context: .
file: src/ServiceBusEmulatorExplorer/Dockerfile
push: false
build-args: |
VERSION=${{ needs.version.outputs.semVer }}
ASSEMBLY_VERSION=${{ needs.version.outputs.majorMinorPatch }}.0
cache-from: type=gha
cache-to: type=gha,mode=max

# Push Docker image only on main branch (not PRs, not forks)
docker-push:
runs-on: ubuntu-latest
needs: [version, build-and-test]
# Only run on main branch pushes, not on tags (release.yml handles tags)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: read
packages: write

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lowercase image name
id: image
run: echo "name=${IMAGE_NAME,,}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -113,8 +141,8 @@ jobs:
VERSION=${{ needs.version.outputs.semVer }}
ASSEMBLY_VERSION=${{ needs.version.outputs.majorMinorPatch }}.0
tags: |
ghcr.io/${{ github.repository }}:${{ needs.version.outputs.semVer }}
ghcr.io/${{ github.repository }}:latest
${{ steps.image.outputs.name }}:${{ needs.version.outputs.semVer }}
${{ steps.image.outputs.name }}:latest
labels: |
org.opencontainers.image.version=${{ needs.version.outputs.semVer }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ jobs:
permissions:
contents: write
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lowercase image name
id: image
run: echo "name=${IMAGE_NAME,,}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -101,9 +107,9 @@ jobs:
VERSION=${{ needs.version.outputs.semVer }}
ASSEMBLY_VERSION=${{ needs.version.outputs.majorMinorPatch }}.0
tags: |
ghcr.io/${{ github.repository }}:${{ needs.version.outputs.semVer }}
ghcr.io/${{ github.repository }}:${{ needs.version.outputs.majorMinorPatch }}
ghcr.io/${{ github.repository }}:latest
${{ steps.image.outputs.name }}:${{ needs.version.outputs.semVer }}
${{ steps.image.outputs.name }}:${{ needs.version.outputs.majorMinorPatch }}
${{ steps.image.outputs.name }}:latest
labels: |
org.opencontainers.image.version=${{ needs.version.outputs.semVer }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
Expand All @@ -119,5 +125,5 @@ jobs:
## Docker Image

```bash
docker pull ghcr.io/${{ github.repository }}:${{ needs.version.outputs.semVer }}
docker pull ${{ steps.image.outputs.name }}:${{ needs.version.outputs.semVer }}
```