Skip to content

Update README with Latest Docs Build #662

Update README with Latest Docs Build

Update README with Latest Docs Build #662

name: Update README with Latest Docs Build
on:
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 "::set-output name=commit::$LATEST_COMMIT"
# - name: Authenticate GitHub CLI
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# echo $GITHUB_TOKEN | gh auth login --with-token
- name: Get latest commit hash from docs folder in headlamp repo
id: get_commit
run: |
export LATEST_COMMIT=$(gh api repos/headlamp-k8s/headlamp/commits --jq '.[0].sha' -F path=docs)
echo "::set-output name=commit::$LATEST_COMMIT"
- name: Update README.md
run: |
COMMIT_HASH=${{ steps.get_commit.outputs.commit }}
README_FILE="README.md"
DOCS_LINK="https://github.com/headlamp-k8s/headlamp/tree/$LATEST_COMMIT/docs"
sed -i "s|^Latest docs build: \[.*\]|Latest docs build: \[$LATEST_COMMIT\]($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 origin update-readme
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}