Update GitBook Documentation with Latest Version #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update GitBook Documentation with Latest Version | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update-gitbook: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout core repository | |
uses: actions/checkout@v3 | |
- name: Get latest release tag from GitHub API | |
id: get_latest_release | |
run: | | |
LATEST_TAG=$(curl -s https://api.github.com/repos/Revxrsal/lamp/releases/latest | jq -r .tag_name) | |
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_ENV | |
- name: Clone GitBook repository | |
run: | | |
git clone https://github.com/Revxrsal/lamp-docs.git | |
cd lamp-docs | |
- name: Update version in README.md | |
run: | | |
cd lamp-docs | |
sed -i 's/[VERSION]/${{ env.LATEST_TAG }}/g' README.md | |
- name: Commit and push changes to GitBook repo | |
run: | | |
cd lamp-docs | |
git config --local user.name "GitHub Action" | |
git config --local user.email "${{ secrets.EMAIL }}" | |
git config --local user.password "${{ secrets.PAT }}" | |
git add README.md | |
git commit -m "Update documentation with version ${{ env.LATEST_TAG }}" | |
git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/Revxrsal/lamp-docs.git | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |