Skip to content

Commit

Permalink
Merge pull request #14 from crabnebula-dev/beanow/curl-user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog-crabnebula authored Oct 16, 2024
2 parents 6e3b1c7 + 70f1904 commit 0f561fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/add-curl-ua.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"action": patch
---

Sets a User-Agent when downloading the CLI.
19 changes: 15 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,30 @@ runs:
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.path }}
env:
# Note: be careful about line-breaks for this parameter. Curl will break when they end up being sent as part of the header.
USER_AGENT: >-
${{
format(
'cloud-release{0} ({1}; {2})',
github.action_ref && format('/{0}',github.action_ref),
runner.os,
runner.arch
)
}}
run: |
: Download CLI
echo "Downloading CLI..."
if [[ "${{ runner.os }}" == "Linux" ]]; then
if [[ "${{ runner.arch }}" == "X64" ]]; then
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-x86_64 --output cn
curl -A "$USER_AGENT" -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-x86_64 --output cn
else
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-aarch64 --output cn
curl -A "$USER_AGENT" -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-aarch64 --output cn
fi
elif [[ "${{ runner.os }}" == "macOS" ]]; then
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/darwin-binary-universal --output cn
curl -A "$USER_AGENT" -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/darwin-binary-universal --output cn
elif [[ "${{ runner.os }}" == "Windows" ]]; then
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/windows-binary-x86_64 --output cn
curl -A "$USER_AGENT" -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/windows-binary-x86_64 --output cn
else
echo "unsupported runner ${{ runner.os }}, only Linux, macOS and Windows are supported"
exit 1
Expand Down

0 comments on commit 0f561fd

Please sign in to comment.