-
Notifications
You must be signed in to change notification settings - Fork 4
42 lines (36 loc) · 1.34 KB
/
update-docs-notice.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
name: Update README with Latest Docs Build
on:
repository_dispatch:
types:
- headlamp-docs-update
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v2
- name: Clone headlamp repository
run: |
git clone https://github.com/headlamp-k8s/headlamp.git
cd headlamp
LATEST_COMMIT=$(git log -n 1 --pretty=format:"%H" -- docs)
echo "LATEST_COMMIT=$LATEST_COMMIT" >> $GITHUB_ENV
- name: Update README.md
run: |
README_FILE="README.md"
DOCS_LINK="https://github.com/headlamp-k8s/headlamp/tree/$LATEST_COMMIT/docs"
LATEST_COMMIT_SHORT=$(echo $LATEST_COMMIT | cut -c1-7)
sed -i "s|^Latest docs build: \[.*\]\(.*\)|Latest docs build: \[$LATEST_COMMIT_SHORT\]($DOCS_LINK)|" $README_FILE
env:
LATEST_COMMIT: ${{ env.LATEST_COMMIT }}
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git checkout -b update-readme
git commit -m "README: Update with latest docs build (automated commit)"
git push -f origin update-readme
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}