Skip to content

Create static directory listings on GitHub Actions/Pages

Posted by author


Remember those classic directory listings from the early days of the web? They're still useful today, especially for some static sites hosted on GitHub Pages.

In this quick tutorial,I'll show you how to automatically create static directory listings on GitHub Actions/Pages with a simple PHP script I created a while back.

Best parts: It's totally free, has no dependencies, and works perfectly in GitHub Actions as they have a built-in PHP runtime.


Here's a screenshot of the directory listing created by the script:

Directory Listing

Trying it locally

To get started, you can try the script locally. Here's how:

Download the script from the GitHub repository:

1wget -O directory-listing.php

Next run the script in your terminal:

1php directory-listing.php

This will create a self-contained index.html file with a directory listing of the current directory.

Using it in GitHub Actions

To use the script in GitHub Actions, you can base it on this sample workflow:

1# GitHub Actions demo to create a directory listing for the repository files to publish to GitHub Pages
3name: Demo Action
6 push:
7 branches: [ "main" ]
10 contents: read
11 pages: write
12 id-token: write
15 build:
16 runs-on: ubuntu-latest
18 steps:
19 - uses: actions/checkout@v3
21 # Download the directory listing script
22 - name: Download Directory Listing Script
23 run: wget -O directory-listing.php
25 # Run the directory listing script
26 - name: Run Directory Listing Script
27 run: php directory-listing.php
29 # Optional: Deploy to GitHub Pages (you can also commit the file to your repository)
30 - name: Setup Pages
31 uses: actions/configure-pages@v5
32 - name: Upload artifact
33 uses: actions/upload-pages-artifact@v3
34 with:
35 path: '.'
36 - name: Deploy to GitHub Pages
37 id: deployment
38 uses: actions/deploy-pages@v4

This workflow will create a directory listing of the repository files and publish it to GitHub Pages.


That's it! You now have a simple way to create static directory listings on GitHub Actions/Pages. Feel free to customize the script or workflow to fit your needs.

See the source code at and try the live demo at

Syntax highlighting by

End of article