name: "embed-src"
description: "A GitHub Action that embeds source files into any text file."
branding:
icon: "file"
color: "gray-dark"
inputs:
files:
description: "Space-separated list of files to process."
required: false
default: "README.md"
commit-message:
description: "The message to associate with the commit containing the modified files."
required: false
default: "chore: embed source files"
commit-name:
description: "Define the name of the committer."
required: false
default: "github-actions[bot]"
commit-email:
description: "Define the email of the committer."
required: false
default: "github-actions[bot]@users.noreply.github.com"
commit-push:
description: "Set to false to skip the push."
required: false
default: "true"
commit-dry:
description: "Set to true to skip the commit."
required: false
default: "false"
github-token:
description: "GitHub token for downloading the binary."
required: false
default: ${{ github.token }}
runs:
using: "composite"
steps:
- name: Configure git identity
shell: bash
run: |
git config user.name "${{ inputs.commit-name }}"
git config user.email "${{ inputs.commit-email }}"
- name: Download embed-src binary
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
set -euo pipefail
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
case "$OS" in
linux) TARGET="${ARCH}-unknown-linux-musl" ;;
darwin) TARGET="${ARCH}-apple-darwin" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
BINARY_NAME="embed-src-${TARGET}"
DOWNLOAD_URL="https://github.com/urmzd/embed-src/releases/latest/download/${BINARY_NAME}"
curl -sSfL "$DOWNLOAD_URL" -o /usr/local/bin/embed-src
chmod +x /usr/local/bin/embed-src
- name: Run embed-src
shell: bash
run: |
# shellcheck disable=SC2086
embed-src ${{ inputs.files }}
- name: Stage, commit, and push
shell: bash
run: |
# shellcheck disable=SC2086
git add ${{ inputs.files }}
if [ "${{ inputs.commit-dry }}" = "false" ]; then
git diff --staged --quiet || git commit -m "${{ inputs.commit-message }}"
fi
if [ "${{ inputs.commit-push }}" = "true" ]; then
git push
fi