Deploy to a single target
There is only one server. The site is served from /var/www/mcg on the VPS at mcg.luxick.de today, and the main domain will be pointed at the same instance at cutover; local `hugo server` covers development. Drops the development/production split from the workflow, its DEPLOY_PATH_DEV / DEPLOY_PATH_PROD secrets and the workflow_dispatch environment input, leaving a single DEPLOY_PATH. baseURL now comes from hugo.toml rather than being injected per environment, so it is the one place to change at cutover. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,16 +5,7 @@ on:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'Deployment target'
|
||||
required: true
|
||||
default: 'development'
|
||||
type: choice
|
||||
options:
|
||||
- development
|
||||
- production
|
||||
workflow_dispatch: # manual re-deploy of the current main
|
||||
|
||||
env:
|
||||
HUGO_VERSION: '0.164.0'
|
||||
@@ -36,35 +27,22 @@ jobs:
|
||||
sudo dpkg -i /tmp/hugo.deb
|
||||
hugo version
|
||||
|
||||
- name: Resolve target
|
||||
id: target
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ] \
|
||||
&& [ "${{ inputs.environment }}" = "production" ]; then
|
||||
echo "base_url=https://motorradclub-giebelwald.de/" >> "$GITHUB_OUTPUT"
|
||||
echo "deploy_path=${{ secrets.DEPLOY_PATH_PROD }}" >> "$GITHUB_OUTPUT"
|
||||
echo "name=production" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "base_url=https://mcg.luxick.de/" >> "$GITHUB_OUTPUT"
|
||||
echo "deploy_path=${{ secrets.DEPLOY_PATH_DEV }}" >> "$GITHUB_OUTPUT"
|
||||
echo "name=development" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# baseURL comes from hugo.toml - that is the single place to change when
|
||||
# the site moves to its final domain.
|
||||
- name: Build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
hugo --gc --minify --baseURL "${{ steps.target.outputs.base_url }}"
|
||||
hugo --gc --minify
|
||||
|
||||
# Pull requests are built to catch breakage, but never published.
|
||||
- name: Deploy to ${{ steps.target.outputs.name }}
|
||||
- name: Deploy
|
||||
if: github.event_name != 'pull_request'
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ steps.target.outputs.deploy_path }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user