mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-30 14:56:11 +00:00
ci(deploy): split per-app deploy into server/workstation/rest workflows (env-only defaults)
- Remove _deploy-per-app.yml (inputs-based indirection) - Add dedicated workflows: - test-deploy-server.yml - test-deploy-workstation.yml - test-deploy-universal.yml (rest) - Configure via env defaults only (KISS / SRP / SPOT) - Update Makefile to target the new workflows and pass overrides via env - Ensure deploy-one-app.sh is executable - Keep failure debug (last 200 chars) and upload logs only outside act
This commit is contained in:
7 files changed
+306
-268
No files matched your search
@@ -1,245 +0,0 @@
|
||||
name: Deploy per app (all distros)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
mode:
|
||||
type: string
|
||||
required: true
|
||||
description: "server | workstation | rest"
|
||||
distros:
|
||||
type: string
|
||||
required: false
|
||||
default: "arch debian ubuntu fedora centos"
|
||||
only_app:
|
||||
type: string
|
||||
required: false
|
||||
default: ""
|
||||
missing_only:
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
keep_stack_on_failure:
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
|
||||
# regex for discovery
|
||||
server_include_re:
|
||||
type: string
|
||||
required: false
|
||||
default: "^(web-app-|web-svc-)"
|
||||
server_exclude_re:
|
||||
type: string
|
||||
required: false
|
||||
default: "^(web-app-oauth2-proxy)$"
|
||||
workstation_include_re:
|
||||
type: string
|
||||
required: false
|
||||
default: "^(desk-|util-desk-)"
|
||||
workstation_exclude_re:
|
||||
type: string
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
mode:
|
||||
description: "server | workstation | rest"
|
||||
required: true
|
||||
default: "server"
|
||||
distros:
|
||||
description: "space-separated list"
|
||||
required: true
|
||||
default: "arch debian ubuntu fedora centos"
|
||||
only_app:
|
||||
description: "optional: run only this app"
|
||||
required: false
|
||||
default: ""
|
||||
missing_only:
|
||||
description: "build only if missing"
|
||||
required: false
|
||||
default: "true"
|
||||
keep_stack_on_failure:
|
||||
description: "keep stack up on failure"
|
||||
required: false
|
||||
default: "true"
|
||||
|
||||
server_include_re:
|
||||
required: false
|
||||
default: "^(web-app-|web-svc-)"
|
||||
server_exclude_re:
|
||||
required: false
|
||||
default: "^(web-app-oauth2-proxy)$"
|
||||
workstation_include_re:
|
||||
required: false
|
||||
default: "^(desk-|util-desk-)"
|
||||
workstation_exclude_re:
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
discover:
|
||||
name: "discover=({{ inputs.mode }})"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
apps: ${{ steps.out.outputs.apps }}
|
||||
deploy_type: ${{ steps.out.outputs.deploy_type }}
|
||||
distros: ${{ steps.out.outputs.distros }}
|
||||
env:
|
||||
NIX_CONFIG: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install jq
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Start stack for discovery (arch)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export INFINITO_DISTRO="arch"
|
||||
make up
|
||||
|
||||
- name: Compute discovery result
|
||||
id: out
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
mode="${{ inputs.mode || github.event.inputs.mode }}"
|
||||
distros="${{ inputs.distros || github.event.inputs.distros }}"
|
||||
only_app="${{ inputs.only_app || github.event.inputs.only_app }}"
|
||||
|
||||
server_include_re="${{ inputs.server_include_re || github.event.inputs.server_include_re }}"
|
||||
server_exclude_re="${{ inputs.server_exclude_re || github.event.inputs.server_exclude_re }}"
|
||||
workstation_include_re="${{ inputs.workstation_include_re || github.event.inputs.workstation_include_re }}"
|
||||
workstation_exclude_re="${{ inputs.workstation_exclude_re || github.event.inputs.workstation_exclude_re }}"
|
||||
|
||||
: "${mode:=server}"
|
||||
: "${distros:=arch debian ubuntu fedora centos}"
|
||||
|
||||
discover() {
|
||||
local include_re="$1"
|
||||
local exclude_re="$2"
|
||||
INCLUDE_RE="${include_re}" EXCLUDE_RE="${exclude_re}" scripts/tests/discover-apps.sh
|
||||
}
|
||||
|
||||
all_json="$(discover '.*' '')"; [[ -n "$all_json" ]] || all_json='[]'
|
||||
server_json="$(discover "${server_include_re}" "${server_exclude_re}")"; [[ -n "$server_json" ]] || server_json='[]'
|
||||
workstation_json="$(discover "${workstation_include_re}" "${workstation_exclude_re}")"; [[ -n "$workstation_json" ]] || workstation_json='[]'
|
||||
|
||||
case "${mode}" in
|
||||
server)
|
||||
apps_json="${server_json}"
|
||||
deploy_type="server"
|
||||
;;
|
||||
workstation)
|
||||
apps_json="${workstation_json}"
|
||||
deploy_type="workstation"
|
||||
;;
|
||||
rest)
|
||||
# rest = all - (server ∪ workstation)
|
||||
apps_json="$(
|
||||
jq -nc \
|
||||
--argjson all "${all_json}" \
|
||||
--argjson server "${server_json}" \
|
||||
--argjson workstation "${workstation_json}" \
|
||||
'
|
||||
def uniq: unique;
|
||||
def union($a;$b): ($a + $b) | uniq;
|
||||
def minus($a;$b): $a | map(select(. as $x | ($b | index($x)) | not));
|
||||
(union($server;$workstation) | uniq) as $covered
|
||||
| minus($all;$covered)
|
||||
| unique
|
||||
'
|
||||
)"
|
||||
deploy_type="server"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid mode=${mode} (server|workstation|rest)" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n "${only_app}" ]]; then
|
||||
apps_json="$(jq -nc --arg a "${only_app}" '[ $a ]')"
|
||||
fi
|
||||
|
||||
echo "apps=${apps_json}" >> "$GITHUB_OUTPUT"
|
||||
echo "deploy_type=${deploy_type}" >> "$GITHUB_OUTPUT"
|
||||
echo "distros=${distros}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
test:
|
||||
name: "deploy:${{ needs.discover.outputs.deploy_type }} app=${{ matrix.app }} (all distros)"
|
||||
needs: discover
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 240
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
# one runner per app, but keep it serial to avoid docker-dind chaos
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
app: ${{ fromJson(needs.discover.outputs.apps) }}
|
||||
|
||||
env:
|
||||
NIX_CONFIG: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install jq
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Run deploy (this app across all distros)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
app="${{ matrix.app }}"
|
||||
deploy_type="${{ needs.discover.outputs.deploy_type }}"
|
||||
distros="${{ needs.discover.outputs.distros }}"
|
||||
|
||||
# normalize bools (workflow_call boolean vs workflow_dispatch string)
|
||||
missing_only="${{ inputs.missing_only || github.event.inputs.missing_only || 'true' }}"
|
||||
keep_stack="${{ inputs.keep_stack_on_failure || github.event.inputs.keep_stack_on_failure || 'true' }}"
|
||||
|
||||
normalize_bool() {
|
||||
case "$1" in
|
||||
true|True|TRUE|1) echo "true" ;;
|
||||
false|False|FALSE|0) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
esac
|
||||
}
|
||||
missing_only="$(normalize_bool "${missing_only}")"
|
||||
keep_stack="$(normalize_bool "${keep_stack}")"
|
||||
|
||||
read -r -a distro_arr <<< "${distros}"
|
||||
|
||||
mkdir -p logs
|
||||
for distro in "${distro_arr[@]}"; do
|
||||
export INFINITO_DISTRO="${distro}"
|
||||
|
||||
echo "=== deploy_type=${deploy_type} distro=${distro} app=${app} ==="
|
||||
args=( --type "${deploy_type}" --app "${app}" )
|
||||
if [[ "${missing_only}" == "true" ]]; then args+=( --missing ); fi
|
||||
if [[ "${keep_stack}" == "true" ]]; then args+=( --keep-stack-on-failure ); fi
|
||||
|
||||
scripts/tests/deploy.sh "${args[@]}"
|
||||
done
|
||||
@@ -2,9 +2,106 @@ name: Test Infinito.Nexus Deploy (server)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
env:
|
||||
# KISS: configure via env only
|
||||
MODE: server
|
||||
DISTROS: "arch debian ubuntu fedora centos"
|
||||
ONLY_APP: ""
|
||||
MISSING_ONLY: "true"
|
||||
KEEP_STACK: "true"
|
||||
NIX_CONFIG: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
server:
|
||||
uses: ./.github/workflows/_deploy-per-app.yml
|
||||
with:
|
||||
mode: server
|
||||
name: deploy:server (per app, all distros)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 240
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install jq
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Start stack for discovery (arch)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export INFINITO_DISTRO="arch"
|
||||
make up
|
||||
|
||||
- name: Discover apps (JSON)
|
||||
id: discover
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
apps="$(MODE="${MODE}" scripts/ci/discover.sh)"
|
||||
[[ -n "${apps}" ]] || apps='[]'
|
||||
|
||||
if [[ -n "${ONLY_APP}" ]]; then
|
||||
apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')"
|
||||
fi
|
||||
|
||||
echo "apps=${apps}" >> "$GITHUB_OUTPUT"
|
||||
echo "apps_json=${apps}"
|
||||
|
||||
- name: Deploy each app (matrix via bash loop)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalize_bool() {
|
||||
case "${1:-}" in
|
||||
true|True|TRUE|1) echo "true" ;;
|
||||
false|False|FALSE|0) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
apps_json='${{ steps.discover.outputs.apps }}'
|
||||
readarray -t apps < <(echo "${apps_json}" | jq -r '.[]')
|
||||
|
||||
export MODE="server"
|
||||
export DISTROS="${DISTROS}"
|
||||
export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")"
|
||||
export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")"
|
||||
|
||||
for app in "${apps[@]}"; do
|
||||
export APP="${app}"
|
||||
scripts/ci/deploy-one-app.sh
|
||||
done
|
||||
|
||||
- name: Show last 200 chars on failure
|
||||
if: failure()
|
||||
shell: bash
|
||||
run: |
|
||||
echo "=== DEBUG: logs ==="
|
||||
ls -la logs || true
|
||||
echo
|
||||
|
||||
shopt -s nullglob
|
||||
for f in logs/*.log; do
|
||||
echo "=== tail -c 200 $f ==="
|
||||
tail -c 200 "$f" || true
|
||||
echo
|
||||
done
|
||||
|
||||
- name: Upload deploy logs
|
||||
if: ${{ always() && env.ACT != 'true' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deploy-logs-server
|
||||
path: logs/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
@@ -2,9 +2,105 @@ name: Test Infinito.Nexus Deploy (universal-rest)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
env:
|
||||
MODE: rest
|
||||
DISTROS: "arch debian ubuntu fedora centos"
|
||||
ONLY_APP: ""
|
||||
MISSING_ONLY: "true"
|
||||
KEEP_STACK: "true"
|
||||
NIX_CONFIG: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
rest:
|
||||
uses: ./.github/workflows/_deploy-per-app.yml
|
||||
with:
|
||||
mode: rest
|
||||
name: deploy:rest (per app, all distros)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 240
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install jq
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Start stack for discovery (arch)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export INFINITO_DISTRO="arch"
|
||||
make up
|
||||
|
||||
- name: Discover apps (JSON)
|
||||
id: discover
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
apps="$(MODE="${MODE}" scripts/ci/discover.sh)"
|
||||
[[ -n "${apps}" ]] || apps='[]'
|
||||
|
||||
if [[ -n "${ONLY_APP}" ]]; then
|
||||
apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')"
|
||||
fi
|
||||
|
||||
echo "apps=${apps}" >> "$GITHUB_OUTPUT"
|
||||
echo "apps_json=${apps}"
|
||||
|
||||
- name: Deploy each app (matrix via bash loop)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalize_bool() {
|
||||
case "${1:-}" in
|
||||
true|True|TRUE|1) echo "true" ;;
|
||||
false|False|FALSE|0) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
apps_json='${{ steps.discover.outputs.apps }}'
|
||||
readarray -t apps < <(echo "${apps_json}" | jq -r '.[]')
|
||||
|
||||
export MODE="rest"
|
||||
export DISTROS="${DISTROS}"
|
||||
export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")"
|
||||
export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")"
|
||||
|
||||
for app in "${apps[@]}"; do
|
||||
export APP="${app}"
|
||||
scripts/ci/deploy-one-app.sh
|
||||
done
|
||||
|
||||
- name: Show last 200 chars on failure
|
||||
if: failure()
|
||||
shell: bash
|
||||
run: |
|
||||
echo "=== DEBUG: logs ==="
|
||||
ls -la logs || true
|
||||
echo
|
||||
|
||||
shopt -s nullglob
|
||||
for f in logs/*.log; do
|
||||
echo "=== tail -c 200 $f ==="
|
||||
tail -c 200 "$f" || true
|
||||
echo
|
||||
done
|
||||
|
||||
- name: Upload deploy logs
|
||||
if: ${{ always() && env.ACT != 'true' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deploy-logs-rest
|
||||
path: logs/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
@@ -1,10 +1,106 @@
|
||||
name: Test Infinito.Nexus Deploy (universal-rest)
|
||||
name: Test Infinito.Nexus Deploy (workstation)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
env:
|
||||
MODE: workstation
|
||||
DISTROS: "arch debian ubuntu fedora centos"
|
||||
ONLY_APP: ""
|
||||
MISSING_ONLY: "true"
|
||||
KEEP_STACK: "true"
|
||||
NIX_CONFIG: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
rest:
|
||||
uses: ./.github/workflows/_deploy-per-app.yml
|
||||
with:
|
||||
mode: rest
|
||||
workstation:
|
||||
name: deploy:workstation (per app, all distros)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 240
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install jq
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Start stack for discovery (arch)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export INFINITO_DISTRO="arch"
|
||||
make up
|
||||
|
||||
- name: Discover apps (JSON)
|
||||
id: discover
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
apps="$(MODE="${MODE}" scripts/ci/discover.sh)"
|
||||
[[ -n "${apps}" ]] || apps='[]'
|
||||
|
||||
if [[ -n "${ONLY_APP}" ]]; then
|
||||
apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')"
|
||||
fi
|
||||
|
||||
echo "apps=${apps}" >> "$GITHUB_OUTPUT"
|
||||
echo "apps_json=${apps}"
|
||||
|
||||
- name: Deploy each app (matrix via bash loop)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalize_bool() {
|
||||
case "${1:-}" in
|
||||
true|True|TRUE|1) echo "true" ;;
|
||||
false|False|FALSE|0) echo "false" ;;
|
||||
*) echo "true" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
apps_json='${{ steps.discover.outputs.apps }}'
|
||||
readarray -t apps < <(echo "${apps_json}" | jq -r '.[]')
|
||||
|
||||
export MODE="workstation"
|
||||
export DISTROS="${DISTROS}"
|
||||
export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")"
|
||||
export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")"
|
||||
|
||||
for app in "${apps[@]}"; do
|
||||
export APP="${app}"
|
||||
scripts/ci/deploy-one-app.sh
|
||||
done
|
||||
|
||||
- name: Show last 200 chars on failure
|
||||
if: failure()
|
||||
shell: bash
|
||||
run: |
|
||||
echo "=== DEBUG: logs ==="
|
||||
ls -la logs || true
|
||||
echo
|
||||
|
||||
shopt -s nullglob
|
||||
for f in logs/*.log; do
|
||||
echo "=== tail -c 200 $f ==="
|
||||
tail -c 200 "$f" || true
|
||||
echo
|
||||
done
|
||||
|
||||
- name: Upload deploy logs
|
||||
if: ${{ always() && env.ACT != 'true' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deploy-logs-workstation
|
||||
path: logs/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
Reference in new issue
Block a user