Create README - LeetHub #1080
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: Generate Table of Contents | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
working-directory: scripts | |
- name: Run table-of-contents.js | |
run: npm run generate-table-of-contents | |
working-directory: scripts | |
- name: Replace README.md in root | |
run: | | |
if cp scripts/README.md README.md; then | |
echo "README.md replaced successfully" | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add README.md | |
git commit -m "Update README with table of contents" | |
git push | |
else | |
echo "Failed to replace README.md" | |
exit 1 | |
fi | |
working-directory: ${{ github.workspace }} |