ci: copy versionsapi binary from container to host

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-01-16 10:08:45 +01:00
parent 467c3f501c
commit 4a6c64a02f
4 changed files with 50 additions and 36 deletions

View File

@ -15,12 +15,8 @@ COPY . .
WORKDIR /workspace/internal/versionsapi/cli
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o versionsapi .
FROM alpine:3.17.1@sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a as release
FROM scratch as release
RUN apk add --no-cache bash
WORKDIR /
COPY --from=builder /workspace/internal/versionsapi/cli/versionsapi .
COPY .github/actions/versionsapi/entrypoint.sh .
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/notIntendedToBeExecuted"]

View File

@ -22,6 +22,9 @@ inputs:
version:
description: --version flag
required: false
version_path:
description: --version-path flag
required: false
add_latest:
description: --latest flag (boolean)
required: false
@ -41,17 +44,41 @@ inputs:
outputs:
output:
description: Output of the command
value: ${{ steps.run.outputs.output }}
runs:
using: docker
image: docker://ghcr.io/edgelesssys/constellation/versionsapi-ci-cli:latest
args:
- ${{ inputs.command }}
- ${{ inputs.ref != '' && format('--ref={0}', inputs.ref) || '' }}
- ${{ inputs.stream != '' && format('--stream={0}', inputs.stream) || '' }}
- ${{ inputs.version != '' && format('--version={0}', inputs.version) || '' }}
- ${{ inputs.add_latest == 'true' && '--latest' || '' }}
- ${{ inputs.add_release == 'true' && '--release' || '' }}
- ${{ inputs.rm_all == 'true' && '--all' || '' }}
- ${{ inputs.dryrun == 'true' && '--dryrun' || '' }}
- --verbose
using: composite
steps:
- name: Get versionsapi binary
shell: bash
run: |
containerID=$(docker create "ghcr.io/edgelesssys/constellation/versionsapi-ci-cli:feat-ci-delete-img-main")
docker cp ${containerID}:/versionsapi .
- name: Run versionsapi
id: run
shell: bash
run: |
out=$(
./versionsapi \
${{ inputs.command }} \
${{ inputs.ref != '' && format('--ref={0}', inputs.ref) || '' }} \
${{ inputs.stream != '' && format('--stream={0}', inputs.stream) || '' }} \
${{ inputs.version != '' && format('--version={0}', inputs.version) || '' }} \
${{ inputs.version_path != '' && format('--version-path={0}', inputs.version_path) || '' }} \
${{ 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.
if [[ ${{ inputs.command == 'list' }} ]]; then
echo "$out" > versionsapi_output.txt
exit 0
fi
echo "output=${outJSON}" >> "$GITHUB_OUTPUT"

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
for arg in "$@"; do
if [[ ${arg} != "" ]]; then
args[${#args[@]}]="${arg}"
fi
done
out=$(/versionsapi "${args[@]}")
if [[ $? -ne 0 ]]; then
exit 1
fi
if [[ ${GITHUB_ACTIONS} == "true" ]]; then
echo "output=${out}" | tee "${GITHUB_ENV}"
else
echo "${out}"
fi

View File

@ -24,6 +24,10 @@ on:
description: --version flag
required: false
type: string
version_path:
description: --version-path flag
required: false
type: string
add_latest:
description: --latest flag
required: false
@ -62,6 +66,10 @@ on:
description: --version flag
required: false
type: string
version_path:
description: --version-path flag
required: false
type: string
add_latest:
description: --latest flag
required: false
@ -172,6 +180,7 @@ jobs:
ref: ${{ inputs.ref }}
stream: ${{ inputs.stream }}
version: ${{ inputs.version }}
version_path: ${{ inputs.version_path }}
add_latest: ${{ inputs.add_latest }}
add_release: ${{ inputs.add_release }}
rm_all: ${{ inputs.rm_all }}