-
Notifications
You must be signed in to change notification settings - Fork 9
69 lines (59 loc) · 2.03 KB
/
readme-to-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Auto generate docs as a new commit for the docs repo
name: update readme to docs
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: read
jobs:
readme-update-to-docs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Get README content
id: get-readme
run: |
cp README.md ../new-src-index.md
- name: see if info is there
run: |
echo "ll .."
ls -al ..
echo "ll ."
ls -al .
- name: add proper description to top of markdown file
run: |
FILE="../new-src-index.md"
TEXT='hi.txt'
echo '---' >> $TEXT
echo 'description: "An extendable WebComponents library for the Spatial Web"' >> $TEXT
echo '---' >> $TEXT
cat $TEXT $FILE > temp && mv temp $FILE
echo "<div class='centered'><a href='https://github.com/volumetrics-io/mrjs/edit/main/README.md' target='_blank'>Suggest an edit on GitHub for README.md</a></div>" >> "$FILE"
cat $FILE
- name: Checkout documentation Repository
uses: actions/checkout@v4
with:
repository: Volumetrics-io/documentation
ref: main
token: ${{ secrets.MRJS_AND_DOCS_REPO_PAT }}
- name: Update Docs
run: |
rm "./source/index.md"
mv -f "../new-src-index.md" "./source/index.md"
- name: Commit only if there are changes
run: |
if [[ -n $(git diff --exit-code) ]]; then
echo "Changes detected. Committing and pushing."
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
commit_message=$'👷 MRjs - Auto Generated README to Index Update 👷\n\nChanges at '"${GITHUB_SHA}"
git add .
git commit -m "$commit_message"
git push --quiet --set-upstream origin HEAD --force
else
echo "No changes detected. Exiting without committing."
fi
env:
GITHUB_TOKEN: ${{ secrets.MRJS_AND_DOCS_REPO_PAT }}