-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
95 lines (85 loc) · 3.19 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: "Preevy Down"
description: "Runs the Preevy `down` command"
author: "Livecycle"
branding:
icon: box
color: blue
inputs:
profile-url:
required: true
description: "The Preevy profile URL"
args:
required: false
description: "Additional args to provide to the `up` command."
docker-compose-yaml-paths:
required: false
description: "Array of comma separated paths to docker compose files. Uses current working directory if not provided."
version:
required: false
description: "Version of Preevy to use. Defaults to latest."
default: latest
node-cache:
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
install:
required: false
description: "EXPERIMENTAL: Installation method of the Preevy CLI. Supported values: npm, gh-release or none"
default: npm
working-directory:
required: false
description: "Working directory where the preevy CLI will run"
outputs: {}
runs:
using: "composite"
steps:
-
uses: actions/setup-node@v4
if: ${{ inputs.install == 'npm' }}
with:
node-version: 18
cache: ${{ inputs.node-cache }}
- name: Install Preevy from GH release
shell: bash
id: install_prevy_gh_release
if: ${{ inputs.install == 'gh-release' }}
run: |
set -eou pipefail
function os_suffix() {
case "${{ runner.os }}" in
"Linux") echo -n "linux";;
"Windows") echo -n "win32";;
"macOS") echo -n "darwin";;
*) 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 -sfL --retry-connrefused --retry 3 https://api.github.com/repos/livecycle/preevy/releases/latest | jq -r .tag_name)
fi
release_file="preevy-${release_version}-$(os_suffix)-$(arch_suffix).tar.gz"
release_url="https://github.com/livecycle/preevy/releases/download/${release_version}/${release_file}"
curl -sfZL --retry-connrefused --retry 3 "${release_url}" | sudo tar -zx -C /usr/local/lib
sudo ln -s /usr/local/lib/preevy/bin/preevy /usr/local/bin/preevy
- name: Run Preevy
shell: bash
working-directory: ${{ inputs.working-directory }}
id: run_preevy
run: |
if [[ ! -z "${{ inputs.docker-compose-yaml-paths }}" ]]; then
opts="-f ${{ inputs.docker-compose-yaml-paths }}"
fi
urls_file=${RUNNER_TEMP}/preevy_urls.${RANDOM}.json
if [[ "${{ inputs.install }}" == "npm" ]]; then
preevy_cmd="npx -- preevy@${{ inputs.version }}"
else
preevy_cmd=preevy
fi
${preevy_cmd} down ${opts} --profile '${{ inputs.profile-url }}' ${{ inputs.args }}