Skip to content

Instantly share code, notes, and snippets.

@taras
Created January 17, 2025 01:09
Show Gist options
  • Save taras/c5a7f8688942d9f29ce1c9650bfc2885 to your computer and use it in GitHub Desktop.
Save taras/c5a7f8688942d9f29ce1c9650bfc2885 to your computer and use it in GitHub Desktop.
name: Staticalize
description: Create a static version of a website by traversing a dynamically evaluated sitemap.xml
author: Frontside Engineering <[email protected]>
inputs:
site:
description: "URL of the website to staticalize. E.g. http://localhost:8000"
required: true
output:
description: Directory to place the downloaded site
required: false
default: dist
base:
description: "Base URL of the public website. E.g. http://frontside.com"
required: true
runs:
using: "composite"
steps:
# Define the binary to use based on the OS
- name: Set binary path and archive name
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ] && [ "${{ runner.arch }}" = "X64" ]; then
echo "ARCHIVE=staticalize-linux.tar.gz" >> $GITHUB_ENV
echo "BINARY=staticalize-linux" >> $GITHUB_ENV
elif [ "${{ runner.os }}" = "Linux" ] && [ "${{ runner.arch }}" = "ARM64" ]; then
echo "ARCHIVE=staticalize-linux-arm64.tar.gz" >> $GITHUB_ENV
echo "BINARY=staticalize-linux-arm64" >> $GITHUB_ENV
elif [ "${{ runner.os }}" = "Windows" ]; then
echo "ARCHIVE=staticalize-windows.zip" >> $GITHUB_ENV
echo "BINARY=staticalize-windows.exe" >> $GITHUB_ENV
elif [ "${{ runner.os }}" = "macOS" ] && [ "${{ runner.arch }}" = "X64" ]; then
echo "ARCHIVE=staticalize-macos.tar.gz" >> $GITHUB_ENV
echo "BINARY=staticalize-macos" >> $GITHUB_ENV
elif [ "${{ runner.os }}" = "macOS" ] && [ "${{ runner.arch }}" = "ARM64" ]; then
echo "ARCHIVE=staticalize-macos-arm64.tar.gz" >> $GITHUB_ENV
echo "BINARY=staticalize-macos-arm64" >> $GITHUB_ENV
else
echo "Unsupported OS or architecture: ${{ runner.os }} / ${{ runner.arch }}"
exit 1
fi
# Download the binary from the release
- name: Download binary from release
shell: bash
run: |
mkdir -p bin
curl -L -o "bin/$ARCHIVE" \
"https://github.com/frontside/staticalize/releases/${VERSION}/download/${ARCHIVE}"
# Extract the binary
- name: Extract binary
shell: bash
run: |
cd bin
if [[ "${{ runner.os }}" == "Windows" ]]; then
unzip "$ARCHIVE"
else
tar xzf "$ARCHIVE"
fi
# Make the binary executable (if needed)
- name: Ensure executable permissions (Linux/macOS only)
shell: bash
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
run: chmod +x "$BINARY"
# Run the binary
- name: Run the selected binary
shell: bash
run: |
"$BINARY" \
--site=${{inputs.site}} \
--output=${{inputs.output}} \
--base=${{inputs.base}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment