Skip to content

Commit 36a22c3

Browse files
authored
Merge pull request #575 from redis/DOC-3970
DOC-3970 Add redis_docs_sync workflow
2 parents d645f92 + c12f1be commit 36a22c3

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: redis_docs_sync
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
type: string
8+
required: true
9+
description: ''
10+
11+
jobs:
12+
redis_docs_sync:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
actions: write
17+
steps:
18+
- name: Generate a token
19+
id: generate-token
20+
uses: actions/create-github-app-token@v1
21+
with:
22+
app-id: ${{ secrets.DOCS_APP_ID }}
23+
private-key: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
24+
25+
- name: 'Checkout'
26+
uses: actions/checkout@v3
27+
with:
28+
token: ${{ steps.generate-token.outputs.token }}
29+
30+
- name: 'Generate modules-api-ref.md file and push if necessary'
31+
env:
32+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
33+
run: |-
34+
RELEASE="${{ github.event.inputs.release }}"
35+
36+
# Generate modules-api-ref.md
37+
gh repo clone redis/redis
38+
pushd redis
39+
git fetch origin --tags
40+
git checkout "tags/${RELEASE}"
41+
utils/generate-module-api-doc.rb > generated-modules-api-ref.md
42+
popd
43+
44+
mv redis/generated-modules-api-ref.md content/develop/reference/modules/modules-api-ref.md
45+
46+
# Apply frontmatter patch
47+
git apply content/develop/reference/modules/modules-api-ref-frontmatter.patch
48+
49+
# Check if there are any changes
50+
modules_api_is_different=$(git diff content/develop/reference/modules/modules-api-ref.md)
51+
52+
# If file has changed, push it to repo
53+
if [[ ! -z $modules_api_is_different ]]; then
54+
git add content/develop/reference/modules/modules-api-ref.md
55+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
56+
git config user.name "github-actions[bot]"
57+
git commit -m "Update modules-api-ref.md for release ${RELEASE}"
58+
git push origin main
59+
fi

0 commit comments

Comments
 (0)