Skip to content

update sync_mintlify_docs to create docs-repo folder if token is missing #2

update sync_mintlify_docs to create docs-repo folder if token is missing

update sync_mintlify_docs to create docs-repo folder if token is missing #2

name: automation | Sync Mintlify Docs

Check failure on line 1 in .github/workflows/sync_mintlify_docs.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/sync_mintlify_docs.yml

Invalid workflow file

(Line: 72, Col: 13): Unrecognized named-value: 'secrets'. Located at position 35 within expression: github.event_name == 'release' && secrets.DOCS_REPO_TOKEN == '', (Line: 78, Col: 13): Unrecognized named-value: 'secrets'. Located at position 32 within expression: github.event_name == 'push' && secrets.DOCS_REPO_TOKEN == '', (Line: 84, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DOCS_REPO_TOKEN != ''
on:
release:
types: [published]
push:
branches:
- feature/cog-4568-make-changelog-generation-automation-testable-and-reliable
permissions:
contents: read
jobs:
sync-mintlify-docs:
if: ${{ github.event_name == 'push' || github.event.release.prerelease == false }}
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Check out core repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prepare release body file
id: release_meta
env:
EVENT_NAME: ${{ github.event_name }}
BRANCH_NAME: ${{ github.ref_name }}
COMMIT_SHA: ${{ github.sha }}
RELEASE_BODY: ${{ github.event.release.body }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
RELEASE_PUBLISHED_AT: ${{ github.event.release.published_at }}
REPOSITORY: ${{ github.repository }}
SERVER_URL: ${{ github.server_url }}
run: |
BODY_FILE="$(mktemp)"
if [ "${EVENT_NAME}" = "release" ]; then
TAG="${RELEASE_TAG}"
RELEASE_LINK="${RELEASE_URL}"
PUBLISHED_AT="${RELEASE_PUBLISHED_AT}"
printf "%s" "${RELEASE_BODY}" > "${BODY_FILE}"
else
SAFE_BRANCH_NAME="${BRANCH_NAME//\//-}"
SHORT_SHA="${COMMIT_SHA::7}"
TAG="test-sync-${SAFE_BRANCH_NAME}-${SHORT_SHA}"
RELEASE_LINK="${SERVER_URL}/${REPOSITORY}/commit/${COMMIT_SHA}"
PUBLISHED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
printf "%s\n\n- Source commit: \`%s\`\n- Workflow event: \`%s\`\n- Commit URL: %s\n" \
"Automated docs sync test run from branch \`${BRANCH_NAME}\`." \
"${COMMIT_SHA}" \
"${EVENT_NAME}" \
"${RELEASE_LINK}" > "${BODY_FILE}"
fi
echo "body_file=${BODY_FILE}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "release_url=${RELEASE_LINK}" >> "$GITHUB_OUTPUT"
echo "published_at=${PUBLISHED_AT}" >> "$GITHUB_OUTPUT"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install Python
run: uv python install
- name: Install dependencies
run: uv sync --locked --all-extras
- name: Verify docs repo token for release syncs
if: ${{ github.event_name == 'release' && secrets.DOCS_REPO_TOKEN == '' }}
run: |
echo "::error::DOCS_REPO_TOKEN secret is required to sync the docs repository on release runs."
exit 1
- name: Prepare temporary docs workspace for push tests
if: ${{ github.event_name == 'push' && secrets.DOCS_REPO_TOKEN == '' }}
run: |
mkdir -p "${GITHUB_WORKSPACE}/docs-repo"
echo "DOCS_REPO_TOKEN is not available; using a temporary docs workspace for push validation."
- name: Check out docs repository
if: ${{ secrets.DOCS_REPO_TOKEN != '' }}
uses: actions/checkout@v6
with:
repository: topoteretes/cognee-docs
token: ${{ secrets.DOCS_REPO_TOKEN }}
ref: main
path: docs-repo
- name: Sync OpenAPI and changelog
run: |
uv run python tools/sync_release_docs.py \
--docs-repo "${GITHUB_WORKSPACE}/docs-repo" \
--tag "${{ steps.release_meta.outputs.tag }}" \
--release-url "${{ steps.release_meta.outputs.release_url }}" \
--published-at "${{ steps.release_meta.outputs.published_at }}" \
--release-body-file "${{ steps.release_meta.outputs.body_file }}"
- name: Preview docs changes
if: ${{ github.event_name == 'push' }}
working-directory: docs-repo
run: |
git status --short
git diff -- cognee_openapi_spec.json changelog.mdx
- name: Commit and push docs changes
if: ${{ github.event_name == 'release' }}
working-directory: docs-repo
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add cognee_openapi_spec.json changelog.mdx
git diff --cached --quiet && exit 0
git commit -m "docs: sync release ${{ steps.release_meta.outputs.tag }}"
git push origin HEAD:main