From 2ce5cc108f392e06e66e50bf3246f7790dcfbb98 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 8 Apr 2024 08:39:58 +0200 Subject: [PATCH] feat(action): migrate bootstrapping step to script --- action.yml | 19 ++----------------- scripts/bootstrap.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 scripts/bootstrap.sh diff --git a/action.yml b/action.yml index f793f1d..479c8f4 100644 --- a/action.yml +++ b/action.yml @@ -74,21 +74,6 @@ runs: - name: "Bootstrap Dataverse service" id: bootstrap shell: bash + working-directory: ${{ github.action_path }}/scripts run: | - echo "::group::🤖 Bootstrap Dataverse service" - mkdir -p "${RUNNER_TEMP}/dv" - touch "${RUNNER_TEMP}/dv/bootstrap.exposed.env" - - docker run -i --network apitest_dataverse \ - -v "${RUNNER_TEMP}/dv/bootstrap.exposed.env:/.env" \ - "${CONFIGBAKER_IMAGE}" bootstrap.sh -e /.env dev - - # Expose outputs - grep "API_TOKEN" "${RUNNER_TEMP}/dv/bootstrap.exposed.env" >> "$GITHUB_OUTPUT" - echo "base_url=http://localhost:8080/" >> "$GITHUB_OUTPUT" - - # Expose version - version=$(curl -s 'http://localhost:8080/api/info/version' | jq -r '.data.version') - echo "dv_version=$version" >>"$GITHUB_OUTPUT" - - echo "::endgroup::" + ./bootstrap.sh diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100644 index 0000000..05733fc --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -euo pipefail + +RUNNER_TEMP=${RUNNER_TEMP:?Must define RUNNER_TEMP env variable before running this script} +CONFIGBAKER_IMAGE=${CONFIGBAKER_IMAGE:?Must define CONFIGBAKER_IMAGE env variable before running this script} +GITHUB_OUTPUT=${GITHUB_OUTPUT:-$(mktemp)} + +mkdir -p "${RUNNER_TEMP}/dv" +touch "${RUNNER_TEMP}/dv/bootstrap.exposed.env" + +echo "::group::🤖 Bootstrap Dataverse service" + +docker run -i --network apitest_dataverse \ + -v "${RUNNER_TEMP}/dv/bootstrap.exposed.env:/.env" \ + "${CONFIGBAKER_IMAGE}" bootstrap.sh -e /.env dev + +echo "::endgroup::" + +# Expose outputs +grep "API_TOKEN" "${RUNNER_TEMP}/dv/bootstrap.exposed.env" >> "$GITHUB_OUTPUT" +echo "base_url=http://localhost:8080/" >> "$GITHUB_OUTPUT" + +# Expose version +version=$(curl -s 'http://localhost:8080/api/info/version' | jq -r '.data.version') +echo "dv_version=$version" >>"$GITHUB_OUTPUT"