2023-01-12 07:17:23 -05:00
|
|
|
name: versionsapi
|
|
|
|
description: "A GitHub Action to interact with the versions API"
|
|
|
|
|
2023-01-12 10:46:51 -05:00
|
|
|
#
|
|
|
|
# !!! Attention !!!
|
|
|
|
#
|
|
|
|
# Calls with command 'add' and 'remove' need synchronization.
|
|
|
|
# Don't use this action directly for these commands.
|
|
|
|
# Use the 'versionsapi' workflow instead.
|
|
|
|
#
|
|
|
|
|
2023-01-12 07:17:23 -05:00
|
|
|
inputs:
|
|
|
|
command:
|
|
|
|
description: Command to run
|
|
|
|
required: true
|
|
|
|
ref:
|
|
|
|
description: --ref flag
|
|
|
|
required: false
|
|
|
|
stream:
|
|
|
|
description: --stream flag
|
|
|
|
required: false
|
|
|
|
version:
|
|
|
|
description: --version flag
|
|
|
|
required: false
|
2023-03-10 04:21:58 -05:00
|
|
|
kind:
|
|
|
|
description: --kind flag
|
|
|
|
required: false
|
2023-01-16 04:08:45 -05:00
|
|
|
version_path:
|
|
|
|
description: --version-path flag
|
|
|
|
required: false
|
2023-01-12 07:17:23 -05:00
|
|
|
add_latest:
|
|
|
|
description: --latest flag (boolean)
|
|
|
|
required: false
|
|
|
|
default: "false"
|
|
|
|
add_release:
|
|
|
|
description: --release flag (boolean)
|
|
|
|
required: false
|
|
|
|
default: "false"
|
|
|
|
rm_all:
|
|
|
|
description: --all flag (boolean)
|
|
|
|
required: false
|
|
|
|
default: "false"
|
|
|
|
dryrun:
|
|
|
|
description: --dryrun flag (boolean)
|
|
|
|
required: false
|
|
|
|
default: "false"
|
|
|
|
outputs:
|
|
|
|
output:
|
|
|
|
description: Output of the command
|
2023-01-16 04:08:45 -05:00
|
|
|
value: ${{ steps.run.outputs.output }}
|
2023-01-12 07:17:23 -05:00
|
|
|
|
|
|
|
runs:
|
2023-01-16 04:08:45 -05:00
|
|
|
using: composite
|
|
|
|
steps:
|
|
|
|
- name: Get versionsapi binary
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-03-07 02:17:27 -05:00
|
|
|
containerID=$(docker create "ghcr.io/edgelesssys/constellation/versionsapi-ci-cli:latest")
|
2023-01-16 04:08:45 -05:00
|
|
|
docker cp ${containerID}:/versionsapi .
|
|
|
|
|
|
|
|
- name: Run versionsapi
|
|
|
|
id: run
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
out=$(
|
|
|
|
./versionsapi \
|
|
|
|
${{ inputs.command }} \
|
2023-02-24 10:26:25 -05:00
|
|
|
${{ inputs.ref != '' && format('--ref="{0}"', inputs.ref) || '' }} \
|
|
|
|
${{ inputs.stream != '' && format('--stream="{0}"', inputs.stream) || '' }} \
|
|
|
|
${{ inputs.version != '' && format('--version="{0}"', inputs.version) || '' }} \
|
2023-03-10 04:21:58 -05:00
|
|
|
${{ inputs.kind != '' && format('--kind="{0}"', inputs.kind) || '' }} \
|
2023-02-24 10:26:25 -05:00
|
|
|
${{ inputs.version_path != '' && format('--version-path="{0}"', inputs.version_path) || '' }} \
|
2023-01-16 04:08:45 -05:00
|
|
|
${{ inputs.add_latest == 'true' && '--latest' || '' }} \
|
|
|
|
${{ inputs.add_release == 'true' && '--release' || '' }} \
|
|
|
|
${{ inputs.rm_all == 'true' && '--all' || '' }} \
|
|
|
|
${{ inputs.dryrun == 'true' && '--dryrun' || '' }}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Multiline output is not supported by GitHub Actions,
|
|
|
|
# and if we encode it, it is redacted as secret. 🤦
|
|
|
|
# So we have to workaround by writing it to a file.
|
|
|
|
|
2023-01-16 11:29:14 -05:00
|
|
|
if [[ ${{ inputs.command }} == 'list' ]]; then
|
2023-01-16 04:08:45 -05:00
|
|
|
echo "$out" > versionsapi_output.txt
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-04-14 12:25:53 -04:00
|
|
|
echo "output=${out}" | tee -a "$GITHUB_OUTPUT"
|