commit 72a9a735ab807cc1b1388bd6a68c0bb21e6bff87 Author: Shaun Hoffer <75172901+SSP6904@users.noreply.github.com> Date: Wed Aug 14 12:16:13 2024 -0400 Added files diff --git a/README.md b/README.md new file mode 100644 index 0000000..9512d6f --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# TTPages action workflow +This repository contains the source code of the TTPages workflow for TTGit Actions. + +## Usage of the workflow + +> Notice: +> +> Make sure you have actions enabled on your account and repository! + +Usage example: + +```yaml +steps: + - name: Publish to TTPages + uses https://git.ttnrtsite.me/actions/ttpages + with: + path: +``` + +The workflow would then look like this: + +```yaml +--- + +name: Publish site + +on: + push: + branches: [main] # Change this if your branch is different + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Publish site + uses: https://git.ttnrtsite.me/actions/ttpages + with: + path: output_folder +``` + +If you use a static site generator, you may add other steps to publish your website data. \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c51e80b --- /dev/null +++ b/action.yml @@ -0,0 +1,16 @@ +--- +name: 'TTPages' +description: 'Publish your static web content for TTPages' + +inputs: + path: + description: 'The path to content to publish' + required: false + default: 'dist' + +runs: + using: 'composite' + steps: + - id: ttpages-action + run: $GITHUB_ACTION_PATH/run.sh '${{ inputs.path }}' + shell: bash \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..da3bcc8 --- /dev/null +++ b/run.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -eo pipefail + +check_command() { + command -v "$1" >/dev/null 2>&1 +} + +if ! check_command git; then + echo "git not found, please install it!" + exit 1 +fi + +if [ $# -ne 1 ]; then + echo "Usage: $(basename "$0") " + exit 1 +fi + +git config --global user.email "support@ttnrtsite.me" +git config --global user.name "TTGit Automation Bot" +git config --global --add --bool push.autoSetupRemote true + +if ! git ls-remote --exit-code --heads origin pages; then + git checkout --orphan pages + git rm -rf . +else + git checkout pages +fi + +if ! [ -d "$1" ]; then + echo "$1 does not exist! Try setting inputs.path" + exit 1 +fi + +cp -r "$1"/* . && rm -rf "$1" +git add -A +git commit -a -m "TTPages: Automated Update" +git push -u \ No newline at end of file