Skip to content

Commit

Permalink
retry releases to get tag name (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubramanianaks authored Jul 6, 2023
1 parent 7fd1688 commit b143ed2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/integration-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
9 changes: 6 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit b143ed2

Please sign in to comment.