-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
91 lines (79 loc) · 2.59 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
name: setup-beaker
description: Set up the Beaker command-line client
branding:
icon: package
color: blue
inputs:
token:
description: Your Beaker token
required: true
workspace:
description: The default workspace to use
required: false
outputs:
account:
description: The name of the authenticated Beaker account
value: ${{ steps.configure-beaker-client.outputs.account }}
runs:
using: composite
steps:
- name: Install Beaker client
shell: bash
run: |
set -euxo pipefail
mkdir -p "$HOME/bin"
TMP=${{ runner.temp }}
VERSION=$(curl --silent https://beaker.org/api/v3/release | jq -r '.version')
echo Downloading Beaker CLI version $VERSION.
ARCH=$(uname -p)
OS=$(uname -s)
if [[ $ARCH == "arm" && $OS == "Darwin" ]]; then
# macOS on M1 chipsets
ARCH=arm64; OS=darwin
elif [[ $ARCH == "i386" && $OS == "Darwin" ]]; then
# macOS on Intel chipsets
ARCH=amd64; OS=darwin
elif [[ $ARCH == "x86_64" && $OS == "Linux" ]]; then
# Linux on AMD64 chipsets
ARCH=amd64; OS=linux
else
echo Unrecognized OS-Architecture combination:
echo ARCH=$ARCH
echo OS=$OS
exit 1
fi
PATTERN="beaker-cli-$OS-$ARCH-$VERSION.tar.gz"
mkdir $TMP/assets/
curl --silent \
--connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
--output $TMP/assets/$PATTERN \
https://beaker.org/api/v3/release/cli\?os\=$OS\&arch\=$ARCH
tar -zxf $TMP/assets/$PATTERN -C $HOME/bin ./beaker
$HOME/bin/beaker --version
# Add to path.
echo "$HOME/bin" >> "$GITHUB_PATH"
- name: Configure Beaker client
id: configure-beaker-client
shell: bash
run: |
set -euo pipefail
beaker config set user_token ${{ inputs.token }}
if [[ ! -z "${{ inputs.workspace }}" ]]; then
beaker config set default_workspace ${{ inputs.workspace }}
fi
# Validate config.
beaker config test > /dev/null
# Setup 'account' output.
account=$(beaker account whoami --format=json | jq -r '.[0].name')
echo "$account"
echo "account=$account" >> $GITHUB_OUTPUT
- name: Print useful config info
shell: bash
run: |
set -euo pipefail
beaker --version
echo "Authenticated as: '${{ steps.configure-beaker-client.outputs.account }}'"