Skip to content

Instantly share code, notes, and snippets.

@intellectronica
Last active December 3, 2025 04:41
Show Gist options
  • Select an option

  • Save intellectronica/81423ddfd75dc0c4bf605932fcecc548 to your computer and use it in GitHub Desktop.

Select an option

Save intellectronica/81423ddfd75dc0c4bf605932fcecc548 to your computer and use it in GitHub Desktop.
Filez - Ad-Hoc File Sharing Using GitHub Pages

GitHub Pages File-Sharing

If you sometimes find yourself needing to share a file over HTTP, there are not many file-sharing solutions you can use.

This action works by publishing files via GitHub Pages behind an obscure prefix path. It updates the repository README with the URLs, so that you have links to the published files.

You can keep the repository secret, and the files are public but semi-secret, so you can share them without concern that other files will be discovered.

Setup

  1. Create a new private repository
  2. Add deploy.yml in .github/workflows
  3. Update DOMAIN to your top level domain and location.href to your github repo
  4. Setup GitHub Pages for the repository with actions-based deployment and with your domain CNAME
  5. Create a filez directory at the top level - that's where you'll add files to share.

That's it. When you add a file to filez/ it will be shared with a prefix and a link to it will be added to the repository README (accessible only to you, since the repository is private).

From the README, you can follow or copy a link and share it.

Repository File Structure

Sample Generated README

πŸ“„ πŸ•
hello.txt 2025-11-28 16:05
mypage.html 2025-11-28 16:10

Happy filesharing!

🫢 Eleanor (@intellectronica)

name: Deploy to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build site and update README
run: |
set -e
DOMAIN="your.domain.name"
OUTPUT_DIR="_site"
mkdir -p "$OUTPUT_DIR"
# Create CNAME file for custom domain
echo "$DOMAIN" > "$OUTPUT_DIR/CNAME"
# Create robots.txt that disallows all crawling
cat > "$OUTPUT_DIR/robots.txt" << 'EOF'
User-agent: *
Disallow: /
EOF
sed -i 's/^ //' "$OUTPUT_DIR/robots.txt"
# Create index.html that redirects to GitHub repo (with noindex)
cat > "$OUTPUT_DIR/index.html" << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">
<meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet, noimageindex">
<script>location.href='https://github.com/your-github-username/your-github-fileshare-repo'</script>
</head>
<body></body>
</html>
EOF
sed -i 's/^ //' "$OUTPUT_DIR/index.html"
# Process each file in filez/
if [ -d "filez" ] && [ "$(ls -A filez 2>/dev/null)" ]; then
find filez -type f | while read -r filepath; do
# Get relative path within filez/
relpath="${filepath#filez/}"
# Get the last commit hash and datetime that modified this file
commit_hash=$(git log -1 --format="%H" -- "$filepath" | cut -c1-12)
commit_datetime=$(git log -1 --date=format:'%Y-%m-%d %H:%M' --format="%cd" -- "$filepath")
commit_timestamp=$(git log -1 --format="%ct" -- "$filepath")
# Compute SHA256 checksum (first 12 chars)
checksum=$(sha256sum "$filepath" | cut -c1-12)
# Create prefix
prefix="${commit_hash}-${checksum}"
# Create output directory structure
output_path="$OUTPUT_DIR/$prefix/$relpath"
mkdir -p "$(dirname "$output_path")"
# Copy file
cp "$filepath" "$output_path"
# Store entry for README: timestamp|datetime|name|url (timestamp for sorting)
echo "${commit_timestamp}|${commit_datetime}|${relpath}|https://$DOMAIN/$prefix/$relpath" >> /tmp/readme_entries.txt
echo "Processed: $relpath -> $prefix/$relpath"
done
fi
# Generate README.md as table sorted by datetime (latest first)
echo "| πŸ“„ | πŸ• |" > README.md
echo "|--|--|" >> README.md
if [ -f /tmp/readme_entries.txt ]; then
sort -t'|' -k1 -nr /tmp/readme_entries.txt | while IFS='|' read -r timestamp datetime name url; do
echo "| [$name]($url) | $datetime |" >> README.md
done
fi
- name: Commit README changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
if git diff --staged --quiet; then
echo "No README changes to commit"
else
git commit -m "Update README with file listings"
git push
fi
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment