Skip to content

Sync Documentation

Sync Documentation #3

Workflow file for this run

name: Sync Documentation
on:
repository_dispatch:
types:
- sync-api-docs
- sync-dataset-docs
- sync-governance-docs
workflow_dispatch:
inputs:
source:
description: 'Source repository to sync from'
required: true
type: choice
options:
- api
- dataset
- governance
ref:
description: 'Git ref (branch/tag/commit) to sync from'
required: false
default: 'main'
type: string
permissions:
contents: write
jobs:
sync-docs:
name: Sync Documentation from ${{ github.event_name == 'workflow_dispatch' && inputs.source || github.event.client_payload.source }}
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Set Source Variables
id: source
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "source=${{ inputs.source }}" >> $GITHUB_OUTPUT
echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT
echo "sha=$(git ls-remote https://github.com/open-ev-data/${{ inputs.source == 'governance' && '.github' || format('open-ev-data-{0}', inputs.source) }} ${{ inputs.ref }} | cut -f1)" >> $GITHUB_OUTPUT
else
echo "source=${{ github.event.client_payload.source }}" >> $GITHUB_OUTPUT
echo "ref=${{ github.event.client_payload.ref }}" >> $GITHUB_OUTPUT
echo "sha=${{ github.event.client_payload.sha }}" >> $GITHUB_OUTPUT
fi
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout Website Repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Checkout Source Repository (API/Dataset)
if: steps.source.outputs.source != 'governance'
uses: actions/checkout@v4
with:
repository: open-ev-data/open-ev-data-${{ steps.source.outputs.source }}
ref: ${{ steps.source.outputs.sha }}
path: source-repo
token: ${{ steps.generate_token.outputs.token }}
- name: Checkout Source Repository (Governance)
if: steps.source.outputs.source == 'governance'
uses: actions/checkout@v4
with:
repository: open-ev-data/.github
ref: ${{ steps.source.outputs.sha }}
path: source-repo
token: ${{ steps.generate_token.outputs.token }}
- name: Sync API Documentation
if: steps.source.outputs.source == 'api'
run: |
mkdir -p docs/api
cp source-repo/README.md docs/api/index.md
cp source-repo/docs/GET_STARTED.md docs/api/
cp source-repo/docs/ARCHITECTURE.md docs/api/
cp source-repo/docs/TESTING.md docs/api/
cp source-repo/docs/RUST_GUIDELINES.md docs/api/
cp source-repo/docs/RELEASE_STRATEGY.md docs/api/
cp source-repo/docs/API_ERRORS.md docs/api/
cp source-repo/docs/PROBLEM_DETAILS_RFC_7807.md docs/api/
cp source-repo/docs/CRATE_EV_CORE.md docs/api/
cp source-repo/docs/CRATE_EV_ETL.md docs/api/
cp source-repo/docs/CRATE_EV_SERVER.md docs/api/
cp source-repo/CHANGELOG.md docs/changelog-api.md
- name: Sync Dataset Documentation
if: steps.source.outputs.source == 'dataset'
run: |
mkdir -p docs/dataset
cp source-repo/README.md docs/dataset/index.md
cp source-repo/docs/HOW_TO_CONSUME.md docs/dataset/
cp source-repo/docs/ARCHITECTURE.md docs/dataset/
cp source-repo/docs/SCHEMA.md docs/dataset/
cp source-repo/docs/RELEASE_PROCESS.md docs/dataset/
cp source-repo/CHANGELOG.md docs/changelog-dataset.md
- name: Sync Governance Documentation
if: steps.source.outputs.source == 'governance'
run: |
mkdir -p docs/governance
cp source-repo/README.md docs/governance/index.md
cp source-repo/GET_STARTED.md docs/governance/GET_STARTED.md
cp source-repo/CONTRIBUTING.md docs/governance/CONTRIBUTING.md
cp source-repo/CODE_OF_CONDUCT.md docs/governance/CODE_OF_CONDUCT.md
- name: Commit and Push Changes
run: |
git add docs/
if git diff --staged --quiet; then
echo "No documentation changes detected"
exit 0
fi
SOURCE="${{ steps.source.outputs.source }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
REF="${{ inputs.ref }}"
VERSION="$REF"
else
VERSION="${{ github.event.client_payload.version }}"
fi
git commit -m "docs($SOURCE): sync documentation from $SOURCE@$VERSION"
git push origin main
echo "✅ Documentation synchronized from $SOURCE"