Skip to content

refactor: shorten link to sibling document (#296) #57

refactor: shorten link to sibling document (#296)

refactor: shorten link to sibling document (#296) #57

name: Deploy GitHub Page (prod)
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Release version prefix (e.g. v5.2.0)'
required: true
type: string
concurrency:
group: deploy-gh-pages-production
cancel-in-progress: false
queue: max
jobs:
deploy-gh-pages:
if: ${{ github.repository == 'siemens/ix-docs' }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate and extract release version
id: release_version
shell: bash
env:
MANUAL_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
numeric_pattern='(0|[1-9][0-9]*)'
identifier_pattern='(0|[1-9][0-9]*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)'
semver_pattern="${numeric_pattern}\.${numeric_pattern}\.${numeric_pattern}(-${identifier_pattern}(\.${identifier_pattern})*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?"
case "$GITHUB_EVENT_NAME" in
workflow_dispatch)
manual_pattern="^v${semver_pattern}$"
if [[ ! "$MANUAL_VERSION" =~ $manual_pattern ]]; then
echo "Malformed manual version; expected v<major>.<minor>.<patch> (with optional SemVer prerelease/build metadata)" >&2
exit 1
fi
echo "version=$MANUAL_VERSION" >> "$GITHUB_OUTPUT"
;;
push)
env_file=".env.production"
if [[ ! -f "$env_file" ]]; then
echo "Expected $env_file to contain IX_REPO_BRANCH='@siemens/ix@<version>'" >&2
exit 1
fi
if grep -Fq '$(' -- "$env_file"; then
echo "Command substitution syntax '\$(' is not allowed in $env_file for automatic deployments" >&2
exit 1
fi
branch_lines=()
while IFS= read -r line || [[ -n "$line" ]]; do
if [[ "$line" =~ ^[[:space:]]*(export[[:space:]]+)?IX_REPO_BRANCH([[:space:]]*=[[:space:]]*|:[[:space:]]+) ]]; then
branch_lines+=("$line")
fi
done < "$env_file"
if (( ${#branch_lines[@]} == 0 )); then
echo "Missing IX_REPO_BRANCH assignment in $env_file" >&2
exit 1
fi
if (( ${#branch_lines[@]} != 1 )); then
echo "Expected exactly one IX_REPO_BRANCH assignment in $env_file" >&2
exit 1
fi
branch_pattern="^IX_REPO_BRANCH='@siemens/ix@(${semver_pattern})'[[:space:]]*$"
if [[ ! "${branch_lines[0]}" =~ $branch_pattern ]]; then
echo "Malformed IX_REPO_BRANCH assignment in $env_file; expected IX_REPO_BRANCH='@siemens/ix@<major>.<minor>.<patch>'" >&2
exit 1
fi
echo "version=v${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
;;
*)
echo "Unsupported event: $GITHUB_EVENT_NAME" >&2
exit 1
;;
esac
- uses: ./.github/workflows/actions/turbo
- name: Remove Pull Request Env
run: rm -f .env.pullrequest
- name: Build
run: pnpm build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC: ${{ secrets.CSC }}
BRAND_URL: ${{ vars.BRAND_URL }}
- name: Deploy GitHub Pages 🚀
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8
with:
folder: ./build
clean-exclude: version-*
- name: Create release version
env:
DEPLOYMENT_VERSION: ${{ steps.release_version.outputs.version }}
id: release_meta
run: |
set -euo pipefail
timestamp=$(date +%d%m%Y%H%M)
release_version="${DEPLOYMENT_VERSION}-${timestamp}"
echo "release_version=${release_version}" >> "$GITHUB_OUTPUT"
- name: Archive build markdown files
run: |
mkdir -p artifacts
find build/docs -type f -name '*.md' | sort > artifacts/markdown-files.txt
if [ ! -s artifacts/markdown-files.txt ]; then
echo "No markdown files found in build output" >&2
exit 1
fi
tar -czf "artifacts/llmstxt.tar.gz" -T artifacts/markdown-files.txt
- name: Create GitHub release with markdown bundle
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: deployment-${{ steps.release_meta.outputs.release_version }}
name: ${{ steps.release_meta.outputs.release_version }}
body: |
Automated release created from `deploy-gh-pages.yml`.
Deployment version: `${{ steps.release_version.outputs.version }}`
files: artifacts/llmstxt.tar.gz
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}