Skip to content

Commit

Permalink
Add composite action to test the setup action
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Apr 12, 2024
1 parent c70d5e3 commit 15f0198
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
name: "Test setup of balena CLI"
description: "Test setup of balena CLI composite action"
# this inputs are always provided by flowzone, so they must always be defined on the composite action
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true
variables:
description: "JSON stringified object containing all the variables from the calling workflow"
required: true
runs:
using: "composite"
steps:
- name: Test setup of balena CLI
uses: ./
with:
cli-version: latest
balena-token: ${{ fromJSON(inputs.secrets).BALENA_API_KEY }}
5 changes: 5 additions & 0 deletions .github/workflows/flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
github.event_name == 'pull_request_target'
)
secrets: inherit
with:
custom_test_matrix: >
{
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
}
18 changes: 5 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ inputs:
balena-token:
description: "balenaCloud API token to login automatically"
required: false
# balena-env:
# description: "balenaCloud environment to use"
# required: false

# Builds and then runs as separate steps as default GitHub method does not allow passing build args
runs:
Expand All @@ -27,7 +24,7 @@ runs:
Linux) echo "slug=linux" >> "${GITHUB_OUTPUT}" ;;
Windows) echo "slug=windows" >> "${GITHUB_OUTPUT}" ;;
macOS) echo "slug=macOS" >> "${GITHUB_OUTPUT}" ;;
*) echo "Unsupported OS: ${{ runner.os }} ; exit 1 ;;
*) echo "Unsupported OS: ${{ runner.os }}" ; exit 1 ;;
esac
- name: Check runner Arch
Expand All @@ -37,7 +34,7 @@ runs:
case ${{ runner.arch }} in
X64) echo "slug=x64" >> "${GITHUB_OUTPUT}" ;;
ARM64) echo "slug=arm64" >> "${GITHUB_OUTPUT}" ;;
*) echo "Unsupported Arch: ${{ runner.arch }} ; exit 1 ;;
*) echo "Unsupported Arch: ${{ runner.arch }}" ; exit 1 ;;
esac
- name: Check CLI version
Expand All @@ -53,33 +50,28 @@ runs:
*) echo "slug=v${INPUT/v/}" >> "${GITHUB_OUTPUT}" ;;
esac
# e.g. https://github.com/balena-io/balena-cli/releases/download/v18.1.9/balena-cli-v18.1.9-linux-arm64-standalone.zip
- name: Download balena CLI
shell: bash
env:
OS: ${{ steps.check_os.outputs.slug }}
ARCH: ${{ steps.check_arch.outputs.slug }}
VERSION: ${{ steps.check_version.outputs.slug }}
run: |
curl -fsSL "https://github.com/balena-io/balena-cli/releases/download/v${VERSION}/balena-cli-v${VERSION}-${OS}-${ARCH}-standalone.zip" -o "${{ runner.temp }}/balena-cli.zip"
curl -fsSL "https://github.com/balena-io/balena-cli/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH}-standalone.zip" -o "${{ runner.temp }}/balena-cli.zip"
- name: Unpack balena CLI
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
unzip "${{ runner.temp }}/balena-cli.zip" -d "${GITHUB_ACTION_PATH}/balena-cli"
unzip "${{ runner.temp }}/balena-cli.zip" -d "${GITHUB_ACTION_PATH}"
echo "${GITHUB_ACTION_PATH}/balena-cli" >> $GITHUB_PATH
- name: Print balena CLI version
shell: bash
run: balena version

# - name: Setup balena environment
# if: inputs.balena-env != ''
# shell: bash
# run: |
# yq '.balenaUrl = "${{ inputs.balena-env}}"' ~/.balenarc.yml

- name: Login to balenaCloud
if: inputs.balena-token != ''
shell: bash
Expand Down

0 comments on commit 15f0198

Please sign in to comment.