-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
96 lines (88 loc) · 3.22 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
96
name: "Setup balena CLI Action"
description: "Setup the balena CLI in a GitHub Actions workflow"
branding:
icon: "code"
color: "blue"
inputs:
cli-version:
description: "balena CLI version to install (example: `v18.1.9`)"
required: false
default: latest
balena-token:
description: "balenaCloud API token to login automatically"
required: false
skip-cache:
description: "Skip using the tool cache and always re-download"
required: false
# Builds and then runs as separate steps as default GitHub method does not allow passing build args
runs:
using: "composite"
steps:
- name: Get latest release
if: inputs.cli-version == 'latest' || inputs.cli-version == ''
id: latest
shell: bash
working-directory: ${{ runner.temp }}
env:
REPO: balena-io/balena-cli
run: |
release="$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r '.tag_name')"
echo "release=${release}" >> "${GITHUB_OUTPUT}"
- name: Restore tool cache
if: inputs.skip-cache != 'true'
id: cache
uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/balena-cli
key: balena-cli-${{ runner.os }}-${{ runner.arch }}-${{ steps.latest.outputs.release || inputs.cli-version }}
- name: Get runner os
if: steps.cache.outputs.cache-hit != true
id: os
shell: bash
working-directory: ${{ runner.temp }}
run: |
case "${{ runner.os }}" in
Linux) echo "target=linux" >> "${GITHUB_OUTPUT}" ;;
macOS) echo "target=macOS" >> "${GITHUB_OUTPUT}" ;;
Windows) echo "target=windows" >> "${GITHUB_OUTPUT}" ;;
*) echo "::error::Unsupported os: ${{ runner.os }}" ; exit 1 ;;
esac
- name: Get runner arch
if: steps.cache.outputs.cache-hit != true
id: arch
shell: bash
working-directory: ${{ runner.temp }}
run: |
case "${{ runner.arch }}" in
X64) echo "target=x64" >> "${GITHUB_OUTPUT}" ;;
ARM64) echo "target=arm64" >> "${GITHUB_OUTPUT}" ;;
*) echo "::error::Unsupported arch: ${{ runner.arch }}" ; exit 1 ;;
esac
- name: Download balena CLI
if: steps.cache.outputs.cache-hit != true
working-directory: ${{ runner.temp }}
shell: bash --noprofile --norc -eo pipefail -x {0}
env:
REPO: balena-io/balena-cli
VERSION: ${{ steps.latest.outputs.release || inputs.cli-version }}
OS: ${{ steps.os.outputs.target }}
ARCH: ${{ steps.arch.outputs.target }}
run: |
curl -fsSL "http://github.com/${REPO}/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH}-standalone.zip" -o balena-cli.zip
unzip balena-cli.zip -d .
- name: Update tool cache
uses: AnimMouse/tool-cache@v1
with:
folder_name: balena-cli
cache_hit: ${{ steps.cache.outputs.cache-hit }}
- name: Print balena CLI version
shell: bash
working-directory: ${{ runner.temp }}
run: balena version
- name: Login to balenaCloud
if: inputs.balena-token != ''
shell: bash
working-directory: ${{ runner.temp }}
run: |
balena login --token "${{ inputs.balena-token }}"
balena whoami