Files
radzen-blazor/.github/workflows/deploy.yml
Vladimir Enchev 668e5c13fa app name fixed
2026-03-16 13:32:27 +02:00

92 lines
2.6 KiB
YAML

name: Deploy to blazor.radzen.com
on:
workflow_dispatch:
concurrency:
group: blazor-radzen-prod
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Generate static assets
run: |
dotnet run --project RadzenBlazorDemos.Tools -- \
RadzenBlazorDemos.Host/wwwroot \
RadzenBlazorDemos/Pages \
RadzenBlazorDemos/Services/ExampleService.cs
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Compute image tag (timestamp)
id: meta
run: |
TAG=$(date -u +"%Y%m%d%H%M%S")
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG}"
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.image }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Set Dokku config
run: |
eval "$(ssh-agent -s)"
echo "${{ secrets.DOKKU_SSH_PRIVATE_KEY }}" | ssh-add -
REMOTE="${{ secrets.DOKKU_REPO }}"
# Extract app name (last path segment) and host, handling both
# ssh://dokku@host:port/app and dokku@host:app formats
APP_NAME=$(echo "$REMOTE" | sed 's|.*/||')
HOST=$(echo "$REMOTE" | sed 's|.*@||;s|[:/].*||')
ssh -o StrictHostKeyChecking=no "dokku@${HOST}" config:set --no-restart "$APP_NAME" "GoogleMaps__ApiKey=${{ secrets.GOOGLE_MAPS_API_KEY }}"
- name: Push to dokku
uses: dokku/github-action@master
with:
git_remote_url: ${{ secrets.DOKKU_REPO }}
ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ steps.meta.outputs.image }}
- name: Prune GHCR versions (keep 1)
uses: actions/delete-package-versions@v5
with:
package-name: radzen-blazor
package-type: container
min-versions-to-keep: 1
delete-only-pre-release-versions: false