27
27
with :
28
28
token : ${{ steps.generate-token.outputs.token }}
29
29
30
- - name : ' Generate modules-api-ref.md file and push if necessary'
30
+ - name : ' Generate modules-api-ref.md and commands.json files and push if necessary'
31
31
env :
32
32
GH_TOKEN : ${{ steps.generate-token.outputs.token }}
33
33
run : |-
@@ -39,27 +39,57 @@ jobs:
39
39
pushd redis
40
40
git fetch origin --tags
41
41
git checkout "tags/${RELEASE}"
42
+ make 1>/dev/null
43
+ src/redis-server &
44
+ utils/generate-commands-json.py > generated-commands.json
42
45
utils/generate-module-api-doc.rb > generated-modules-api-ref.md
43
46
popd
44
47
45
- git checkout -b "${BRANCH}"
48
+ # check if remote branch already exists
49
+ git ls-remote --exit-code --heads origin "refs/heads/${BRANCH}"
50
+ if [ "$?" -eq 0 ]; then
51
+ # if it does, create local branch off existing remote branch
52
+ git checkout -b "${BRANCH}" "origin/${BRANCH}"
53
+ git branch --set-upstream-to="origin/${BRANCH}" "${BRANCH}"
54
+ git pull
55
+ else
56
+ # otherwise, create local branch from main
57
+ git checkout -b "${BRANCH}"
58
+ fi
46
59
47
60
mv redis/generated-modules-api-ref.md content/develop/reference/modules/modules-api-ref.md
61
+ mv redis/generated-commands.json data/commands_core.json
48
62
49
63
# Apply frontmatter patch
50
64
git apply content/develop/reference/modules/modules-api-ref-frontmatter.patch
51
-
65
+
52
66
# Check if there are any changes
67
+ commands_core_is_different=$(git diff data/commands_core.json)
53
68
modules_api_is_different=$(git diff content/develop/reference/modules/modules-api-ref.md)
54
69
55
- # If file has changed, push it to repo
70
+ # If commands_core file has changed, commit it
71
+ if [[ ! -z $commands_core_is_different ]]; then
72
+ git add data/commands_core.json
73
+ git config user.email "177626021+redisdocsapp[bot]@users.noreply.github.com"
74
+ git config user.name "redisdocsapp[bot]"
75
+ git commit -m "Update commands_core.json for release ${RELEASE}"
76
+ fi
77
+
78
+ # If modules-api-ref file has changed, commit it
56
79
if [[ ! -z $modules_api_is_different ]]; then
57
80
git add content/develop/reference/modules/modules-api-ref.md
58
81
git config user.email "177626021+redisdocsapp[bot]@users.noreply.github.com"
59
82
git config user.name "redisdocsapp[bot]"
60
83
git commit -m "Update modules-api-ref.md for release ${RELEASE}"
84
+ fi
85
+
86
+ if [[ ! -z $commands_core_is_different || ! -z $modules_api_is_different ]]; then
61
87
git push origin "${BRANCH}"
88
+ fi
62
89
90
+ # If a pr is not already open, create one
91
+ gh search prs -R redis-learn/docs --state open --match title "redis docs ${RELEASE}" | grep -q "redis docs ${RELEASE}"
92
+ if [ "$?" -eq 1 ]; then
63
93
gh pr create \
64
94
--body "redis docs sync ${RELEASE}" \
65
95
--title "redis docs sync ${RELEASE}" \
0 commit comments