diff --git a/.github/workflows/integration-install.yml b/.github/workflows/integration-install.yml index 1a23c5d0..8a7609a3 100644 --- a/.github/workflows/integration-install.yml +++ b/.github/workflows/integration-install.yml @@ -11,9 +11,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 + - name: Get Draft Cli version + uses: actions/github-script@v6 + id: get_draft_version + with: + result-encoding: string + retries : 3 + script: | + const tag_url = context.payload.repository.releases_url.replace('{/id}', '/latest'); + const response = await github.request(tag_url); + return response.data.tag_name; - name: Run Install Script shell: bash run: ./scripts/install.sh + env: + DRAFT_CLI_VERSION: ${{ steps.get_draft_version.outputs.result }} - name: Validate Command is Installed shell: bash run: | diff --git a/scripts/install.sh b/scripts/install.sh index 8d8b914a..39c708c7 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -112,9 +112,12 @@ download_draft_cli_stable_version(){ FILENAME="draft-$OS-$ARCH" fi log INFO "Starting Draft CLI Download for $FILENAME" - DRAFTCLIVERSION=$(curl -L -s https://api.github.com/repos/Azure/draft/releases/latest | jq -r '.tag_name') - log INFO "Starting Draft CLI Version $DRAFTCLIVERSION" - DRAFTCLIURL="https://github.com/Azure/draft/releases/download/$DRAFTCLIVERSION/$FILENAME" + # For Github actions integration-install tests DRAFT_CLI_VERSION will be set an env variable i.e., check integration-install.yml, but when the user runs the script locally, it will be empty. + if [ -z "${DRAFT_CLI_VERSION}" ]; then + DRAFT_CLI_VERSION=$(curl -L -s https://api.github.com/repos/Azure/draft/releases/latest | jq -r '.tag_name') + fi + log INFO "Draft CLI Version $DRAFT_CLI_VERSION" + DRAFTCLIURL="https://github.com/Azure/draft/releases/download/$DRAFT_CLI_VERSION/$FILENAME" curl -o /tmp/draftcli -fLO $DRAFTCLIURL chmod +x /tmp/draftcli log INFO "Finished Draft CLI download complete."