added secret token to avoid 403 #4
This file contains hidden or 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 Subdirectory List | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: true | |
| ref: main # Make sure to track the actual branch | |
| - name: Generate subdirectories.json | |
| run: | | |
| echo "[" > subdirectories.json | |
| for dir in */ ; do | |
| if [[ "$dir" != "assets/" && "$dir" != ".github/" ]]; then | |
| echo " \"${dir%/}\"," >> subdirectories.json | |
| fi | |
| done | |
| sed -i '$ s/,$//' subdirectories.json | |
| echo "]" >> subdirectories.json | |
| - name: Commit and push | |
| env: | |
| TOKEN: ${{ secrets.SUBDIRECTORYFETCHINGTOKEN }} | |
| run: | | |
| git config user.name "Auto Commit Bot" | |
| git config user.email "[email protected]" | |
| git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }} | |
| git add subdirectories.json | |
| git commit -m "Update subdirectories list" || echo "No changes" | |
| git push origin main |