Skip to content

Commit

Permalink
Update directory-listing.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
aykhan019 authored Sep 15, 2024
1 parent b6d1b84 commit a278d70
Showing 1 changed file with 24 additions and 46 deletions.
70 changes: 24 additions & 46 deletions .github/workflows/directory-listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,32 @@ name: Generate Directory Listings
on:
push:
branches:
- master # Change to 'main' if that is your default branch name
- main

jobs:
build:
runs-on: ubuntu-latest

# Set permissions to write to repository contents
permissions:
contents: write
pages: write
id-token: write

steps:
# Checkout the repository
- uses: actions/checkout@v3

# Download the directory listing script
- name: Download Directory Listing Script
run: wget https://raw.githubusercontent.com/caendesilva/php-directory-listing/master/directory-listing.php -O directory-listing.php

# Run the directory listing script
- name: Run Directory Listing Script
run: php directory-listing.php

# Configure Git for committing changes
- name: Configure Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
# Commit and Push Changes
- name: Commit and Push Changes
env:
ACTIONS_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git add .
git commit -m 'Add directory listings'
git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }} HEAD:${{ github.ref }}
# Optional: Deploy to GitHub Pages (if needed)
- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Run directory listing generator
run: |
find . -type d | while read dir; do
cd "$dir"
php /path/to/directory-listing.php
cd -
done
- name: Commit and push changes
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
git add .
git commit -m "Update directory listings"
git push

0 comments on commit a278d70

Please sign in to comment.