-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
112 lines (103 loc) · 3.8 KB
/
action.yaml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: 'Garden Action'
description: 'GitHub actions for Garden'
branding:
color: green
icon: check-circle
inputs:
command:
description: |
All command line options for the garden cli command.
If not provided, the garden-action will
- install garden and export it to the `PATH` environment variable for subsequent steps
- export the `GARDEN_AUTH_TOKEN` environment variable for subsequent steps if the `garden-auth-token` input has been provided
required: false
logger-type:
description: 'Garden logger type. Defaults to basic.'
required: false
default: basic
log-level:
description: 'Garden log level. Defaults to verbose.'
required: false
default: verbose
garden-version:
description: 'Garden version. Defaults to latest stable.'
required: false
default: 'latest'
garden-auth-token:
description: 'An auth token to authenticate in case your project is connected to Garden Cloud. Optional.'
required: false
garden-workdir:
description: |
A path to a garden project in a repository.
Only necessary if there are multiple garden projects in a repository, or when the project.garden.yml is in a subdirectory.
github-token:
description: 'Github token for releases API. Required. Defaults to the `github.token` context variable.'
required: true
default: ${{ github.token }}
runs:
using: "composite"
steps:
- name: prepare
shell: bash
env:
garden_auth_token: ${{ inputs.garden-auth-token }}
github_token: ${{ inputs.github-token }}
run: |
# Prepare
# Mask secrets
[[ "${garden_auth_token}" != "" ]] && echo "::add-mask::${garden_auth_token}"
[[ "${github_token}" != "" ]] && echo "::add-mask::${github_token}"
- name: download garden
shell: bash
env:
garden_version: ${{ inputs.garden-version }}
GH_TOKEN: ${{ inputs.github-token }}
GARDEN_DIR: ${{ runner.temp }}/garden
run: |
# Install Garden
mkdir -p "$GARDEN_DIR"
cd "$GARDEN_DIR"
if ! [ -d "$garden_version" ]; then
echo "Downloading ${garden_version}..."
if [[ "$garden_version" = "latest" ]]; then
tag_param=""
else
tag_param="$garden_version"
fi
# TODO: Consider using download.garden.io
gh release download "$tag_param" --pattern '*-linux-amd64.tar.gz' -R garden-io/garden
gh release download "$tag_param" --pattern '*-linux-amd64.tar.gz.sha256' -R garden-io/garden
checksum=$(openssl dgst -sha256 *-linux-amd64.tar.gz | awk '{ print $2 }')
if [ "$checksum" != "$(cat *-linux-amd64.tar.gz.sha256)" ]; then
echo "Checksum validation failed." >&2
exit 1
fi
tar xzf *-linux-amd64.tar.gz
rm *-linux-amd64.tar.gz *.sha256
mkdir -p "$garden_version"
mv linux-amd64/* "$garden_version"
fi
# Create new symlink, or overwrite existing
ln -sfn "$garden_version" bin
echo "Using $(bin/garden version)"
echo "$GARDEN_DIR/bin" >> "$GITHUB_PATH"
- name: run garden
if: inputs.command
shell: bash
env:
command: ${{ inputs.command }}
GARDEN_AUTH_TOKEN: ${{ inputs.garden-auth-token }}
GARDEN_LOGGER_TYPE: ${{ inputs.logger-type }}
GARDEN_LOG_LEVEL: ${{ inputs.log-level }}
working-directory: ${{ inputs.garden-workdir }}
run: garden ${command}
- name: export variables
if: ${{ !inputs.command }}
shell: bash
env:
garden_auth_token: ${{ inputs.garden-auth-token }}
run: |
# Export environment variables
if [[ "${garden_auth_token}" != "" ]]; then
echo "GARDEN_AUTH_TOKEN=${garden_auth_token}" >> "$GITHUB_ENV"
fi