Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add composite action to test the setup action #1

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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