Skip to content

Commit 0ddcb92

Browse files
update sync_release_docs workflow
1 parent 7fccbc9 commit 0ddcb92

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

.github/workflows/sync_mintlify_docs.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ name: automation | Sync Mintlify Docs
33
on:
44
release:
55
types: [published]
6+
push:
7+
branches:
8+
- feature/cog-4568-make-changelog-generation-automation-testable-and-reliable
69

710
permissions:
811
contents: read
912

1013
jobs:
1114
sync-mintlify-docs:
12-
if: ${{ github.event.release.prerelease == false }}
15+
if: ${{ github.event_name == 'push' || github.event.release.prerelease == false }}
1316
runs-on: ubuntu-22.04
1417
timeout-minutes: 20
1518

@@ -22,11 +25,39 @@ jobs:
2225
- name: Prepare release body file
2326
id: release_meta
2427
env:
28+
EVENT_NAME: ${{ github.event_name }}
29+
BRANCH_NAME: ${{ github.ref_name }}
30+
COMMIT_SHA: ${{ github.sha }}
2531
RELEASE_BODY: ${{ github.event.release.body }}
32+
RELEASE_TAG: ${{ github.event.release.tag_name }}
33+
RELEASE_URL: ${{ github.event.release.html_url }}
34+
RELEASE_PUBLISHED_AT: ${{ github.event.release.published_at }}
35+
REPOSITORY: ${{ github.repository }}
36+
SERVER_URL: ${{ github.server_url }}
2637
run: |
2738
BODY_FILE="$(mktemp)"
28-
printf "%s" "${RELEASE_BODY}" > "${BODY_FILE}"
39+
if [ "${EVENT_NAME}" = "release" ]; then
40+
TAG="${RELEASE_TAG}"
41+
RELEASE_LINK="${RELEASE_URL}"
42+
PUBLISHED_AT="${RELEASE_PUBLISHED_AT}"
43+
printf "%s" "${RELEASE_BODY}" > "${BODY_FILE}"
44+
else
45+
SAFE_BRANCH_NAME="${BRANCH_NAME//\//-}"
46+
SHORT_SHA="${COMMIT_SHA::7}"
47+
TAG="test-sync-${SAFE_BRANCH_NAME}-${SHORT_SHA}"
48+
RELEASE_LINK="${SERVER_URL}/${REPOSITORY}/commit/${COMMIT_SHA}"
49+
PUBLISHED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
50+
printf "%s\n\n- Source commit: \`%s\`\n- Workflow event: \`%s\`\n- Commit URL: %s\n" \
51+
"Automated docs sync test run from branch \`${BRANCH_NAME}\`." \
52+
"${COMMIT_SHA}" \
53+
"${EVENT_NAME}" \
54+
"${RELEASE_LINK}" > "${BODY_FILE}"
55+
fi
56+
2957
echo "body_file=${BODY_FILE}" >> "$GITHUB_OUTPUT"
58+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
59+
echo "release_url=${RELEASE_LINK}" >> "$GITHUB_OUTPUT"
60+
echo "published_at=${PUBLISHED_AT}" >> "$GITHUB_OUTPUT"
3061
3162
- name: Install uv
3263
uses: astral-sh/setup-uv@v7
@@ -49,17 +80,25 @@ jobs:
4980
run: |
5081
uv run python tools/sync_release_docs.py \
5182
--docs-repo "${GITHUB_WORKSPACE}/docs-repo" \
52-
--tag "${{ github.event.release.tag_name }}" \
53-
--release-url "${{ github.event.release.html_url }}" \
54-
--published-at "${{ github.event.release.published_at }}" \
83+
--tag "${{ steps.release_meta.outputs.tag }}" \
84+
--release-url "${{ steps.release_meta.outputs.release_url }}" \
85+
--published-at "${{ steps.release_meta.outputs.published_at }}" \
5586
--release-body-file "${{ steps.release_meta.outputs.body_file }}"
5687
88+
- name: Preview docs changes
89+
if: ${{ github.event_name == 'push' }}
90+
working-directory: docs-repo
91+
run: |
92+
git status --short
93+
git diff -- cognee_openapi_spec.json changelog.mdx
94+
5795
- name: Commit and push docs changes
96+
if: ${{ github.event_name == 'release' }}
5897
working-directory: docs-repo
5998
run: |
6099
git config user.name "github-actions[bot]"
61100
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
62101
git add cognee_openapi_spec.json changelog.mdx
63102
git diff --cached --quiet && exit 0
64-
git commit -m "docs: sync release ${{ github.event.release.tag_name }}"
103+
git commit -m "docs: sync release ${{ steps.release_meta.outputs.tag }}"
65104
git push origin HEAD:main

0 commit comments

Comments
 (0)