Skip to content

Commit

Permalink
Merge pull request #23 from hydephp/add-root-directory-path-option
Browse files Browse the repository at this point in the history
Add root directory path option
  • Loading branch information
caendesilva authored Nov 25, 2023
2 parents fac77a0 + 3847aff commit 68868ec
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ There are a few more configuration options available, that can be supplied to th
| `upload-artifact` | Upload the site artifact, regardless of the `deploy-to` option | `false` |
| `debug` | Enable additional debug output | `false` |
| `framework-version` | Specify the HydePHP Framework version to use<br><small>(only applicable for [anonymous projects](https://hydephp.github.io/action/#anonymous-projects))</small> | "latest" |
| `directory` | The directory to use as the project root | none |
| `env-site-name` | Set the `SITE_NAME` environment variable | _none_ |
| `env-site-url` | Set the `SITE_URL` environment variable | _none_ |
| `env-torchlight-token` | Set the `TORCHLIGHT_TOKEN` environment variable | _none_ |
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ inputs:
required: false
default: "latest"

directory:
description: 'The project root directory'
required: false
default: "."

env-site-name:
description: 'Set the `SITE_NAME` environment variable'
required: false
Expand Down Expand Up @@ -54,6 +59,11 @@ runs:
run: bash validate-input.sh ${{ inputs.deploy-to }}
shell: bash

- name: Configure root directory
id: configure-root-directory
run: bash configure-root-directory.sh ${{ inputs.directory }}
shell: bash

- name: Determine install strategy
id: determine-install-strategy
run: bash determine-install-strategy.sh
Expand Down
19 changes: 19 additions & 0 deletions configure-root-directory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# If the directory input is not the root directory, we replace the current working directory files with the directory
# input files. This way is more reliable, as GitHub does not support setting a working directory on a job level.

# Get directory from CLI input
directory=$1

if [ "$directory" != "." ]; then
# Create a temporary directory outside of the current working directory.
mkdir ../tmp
# Copy the directory input files recursively to the temporary directory.
cp -r "$directory"/* ../tmp
# Remove the current working directory files.
rm -rf ./*
# Copy the temporary directory files to the current working directory.
cp -r ../tmp/* .

# Remove the temporary directory.
rm -rf ../tmp
fi
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ This is only used when the anonymous project strategy is used, (i.e. when the pr
* **Required**: `false`
* **Default**: `"latest"`

### `directory`

Specifies the directory containing the source files to build. This is useful if your source files are not located in the root directory of the repository.

* **Description**: Specify the directory containing the source files to build.
* **Required**: `false`
* **Default**: `"."`

### Environment variables

>warning If your inputs contain sensitive information, you should use [GitHub Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to store them.
Expand Down
12 changes: 8 additions & 4 deletions download-latest-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
# Get version from CLI input
version=$1

# Copy all root files to backup directory
cp -r . ../backup
# Copy all root files to temporary backup directory
cp -r . ../tmp
# Download latest version of HydePHP
git clone https://github.com/hydephp/hyde.git ../hyde --depth 1
# Copy HydePHP files to root
cp -r ../hyde/* .

# Remove default pages
rm _pages/index.blade.php _pages/404.blade.php
# Copy Backup files to root
cp -r ../backup/* .
cp -r ../tmp/* .

# Remove the temporary directory.
rm -rf ../tmp

# If version is set to something other than latest, require that framework version
if [[ "$version" != "latest" ]]; then
composer require hyde/framework:"$version" --no-install
composer require hyde/framework:"$version" --no-install
fi

0 comments on commit 68868ec

Please sign in to comment.