Skip to content

Commit

Permalink
add option to install from a gh release
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Razon committed Dec 20, 2023
1 parent 32baf3e commit daeedd6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,27 @@ Optional additional args to the `preevy up` command, see the full reference [her

The preevy [CLI version](https://www.npmjs.com/package/preevy?activeTab=versions) to use. Defaults to `latest`.

***Note*** Version `v2.1.0` of this action supports Preevy CLI versions `0.0.58` and up. To use an older version of the CLI, use `livecycle/[email protected]`.
***Note*** Since `v2.1.0`, this action requires Preevy CLI version `v0.0.58` or newer. To use an older version of the CLI, use `livecycle/[email protected]`.

### `docker-compose-yaml-paths`

*required*: `false`

Optional path to the `docker-compose.yaml` file. If not provided, uses the working directory. If you have multiple docker compose files, you can add them as a comma seperated string like so `'docker-compose.yml,docker-compose.dev.yml'`

### `release-type`

*required*: `false`

***EXPERIMENTAL***. Specify `gh-release` to install Preevy from a binary file, which is much faster than using NPM.

If this option is specified, `version` can be either `latest` or one of the [released versions](https://github.com/livecycle/preevy/releases). Canary versions are not supported.

### `node-cache`

*required*: `false`

Node package manager used for caching. Supported values: npm, yarn, pnpm, or ''. [Details](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data). Default: npm.
Node package manager used for caching. Supported values: `npm`, `yarn`, `pnpm`, or ''. [Details](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data). Default: `npm`.

## Outputs

Expand Down Expand Up @@ -111,7 +119,7 @@ jobs:

- uses: actions/checkout@v3

- uses: livecycle/preevy-up-action@v2.1.0
- uses: livecycle/preevy-up-action@v2.2.0
id: preevy
with:
# Create the profile using the `preevy init` command, see
Expand Down Expand Up @@ -189,7 +197,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: livecycle/preevy-up-action@v2.1.0
- uses: livecycle/preevy-up-action@v2.2.0
id: preevy_up
with:
# Create the profile using the `preevy init` command, see
Expand Down
50 changes: 48 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
required: false
description: "Node package manager used for caching. Supported values: npm, yarn, pnpm, or ''. See https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data"
default: npm
release-type:
required: false
description: "EXPERIMENTAL: Type of release to use. Supported values: npm, gh-release"
default: npm
outputs:
urls-json:
description: "The generated URLs of the preview environments create by Preevy, formatted as a JSON object"
Expand All @@ -32,11 +36,47 @@ outputs:
runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
-
uses: actions/setup-node@v4
if: ${{ inputs.release-type == 'npm' }}
with:
node-version: 18
cache: ${{ inputs.node-cache }}

- name: Install Preevy from GH release
shell: bash
id: install_prevy_gh_release
if: ${{ inputs.release-type == 'gh-release' }}
run: |
set -eou pipefail
function os_suffix() {
case "${{ runner.os }}" in
"Linux") echo -n "linux";;
"Windows") echo -n "win";;
"macOS") echo -n "macos";;
*) echo "No release for OS ${{ runner.os }}" 1>&2; exit 1;;
esac
}
function arch_suffix() {
case "${{ runner.arch }}" in
"X64") echo -n "x64";;
"ARM64") echo -n "arm64";;
*) echo "No release for arch ${{ runner.arch }}" 1>&2; exit 1;;
esac
}
release_version='${{ inputs.version }}'
if [[ "${{ inputs.version }}" == "latest" ]]; then
release_version=$(curl -s https://api.github.com/repos/livecycle/preevy/releases/latest | jq -r .tag_name)
fi
release_file="preevy-$(os_suffix)-$(arch_suffix).tar"
release_url="https://github.com/livecycle/preevy/releases/download/${release_version}/${release_file}"
wget -q "${release_url}" -O - | sudo tar -x -C /usr/local/bin
- name: Run Preevy
shell: bash
id: run_preevy
Expand All @@ -47,7 +87,13 @@ runs:
urls_file=${RUNNER_TEMP}/preevy_urls.${RANDOM}.json
npx -- preevy@${{ inputs.version }} up ${opts} --profile '${{ inputs.profile-url }}' --output-urls-to ${urls_file} ${{ inputs.args }}
if [[ "${{ inputs.release-type }}" == "npm" ]]; then
preevy_cmd="npx -- preevy@${{ inputs.version }}"
else
preevy_cmd=preevy
fi
${preevy_cmd} up ${opts} --profile '${{ inputs.profile-url }}' --output-urls-to ${urls_file} ${{ inputs.args }}
cat ${urls_file}
Expand Down

0 comments on commit daeedd6

Please sign in to comment.