Skip to content

Dev to Master

Dev to Master #29

Workflow file for this run

name: Docs Site
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
concurrency:
# PR updates may cancel their own validation, never a production deployment.
group: ${{ github.event_name == 'pull_request' && format('docs-site-pr-{0}', github.event.pull_request.number) || 'ultimateauth-deploy' }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
changes:
name: Changes
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
site: ${{ steps.filter.outputs.site }}
steps:
- name: Detect changed files
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
site:
- 'docs/**'
- 'src/utilities/CodeBeam.UltimateAuth.DocsBuilder/**'
- 'Directory.Build.props'
- 'Directory.Build.targets'
- 'Directory.Packages.props'
- 'global.json'
- 'NuGet.Config'
- 'nuget.config'
- '.dockerignore'
- '.docker/Dockerfile'
- '.docker/docker-compose.yml'
- '.github/workflows/deploy.yml'
build:
name: Docker Build
needs: changes
# Master and manual builds do not depend on a PR-only detector succeeding.
if: >-
!cancelled() &&
(github.event_name != 'pull_request' ||
(needs.changes.result == 'success' && needs.changes.outputs.site == 'true'))
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: .docker/Dockerfile
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
tags: |
ghcr.io/codebeamorg/ultimateauth:master
ghcr.io/codebeamorg/ultimateauth:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy
needs: build
if: >-
!cancelled() &&
needs.build.result == 'success' &&
github.event_name != 'pull_request' &&
github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
set -e
cd ~/apps/UltimateAuth
git fetch origin master
git reset --hard origin/master
echo "Deploying commit:"
git log -1 --oneline
cd .docker
docker compose pull
docker compose up -d --remove-orphans
docker image prune -f