Skip to content

Allow url as devbox-version #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,16 @@ jobs:
sha256-checksum: '169836de22c41a1c68ac5a43e0514d4021137647c7c08ee8bd921faa430ee286'
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"


test-action-with-url-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install devbox
uses: ./
with:
devbox-version: https://nightly-ubuntu.dev-jetify.com/
refresh-cli: true
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"
33 changes: 31 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inputs:
description: 'Specify whether the CLI should be redownloaded'
default: 'false'
devbox-version: # version of the devbox cli
description: 'Specify devbox CLI version you want to pin to. Default to latest'
description: 'Specify devbox CLI version you want to pin to. Default to latest release. If version is URL, the URL will be downloaded and used as the devbox binary, assumed to be zipped.'
default: ''
sha256-checksum: # the expected SHA256 checksum of the devbox binary.
description: 'Specify an explicit checksum for the devbox binary. For extra security on top of the existing checks in the devbox launch script'
Expand All @@ -35,7 +35,36 @@ runs:
DEVBOX_USE_VERSION: ${{ inputs.devbox-version }}
run: |
if [[ -n $DEVBOX_USE_VERSION ]]; then
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
if [[ "$DEVBOX_USE_VERSION" =~ ^https?:// ]]; then
# If version is a URL, download and extract it
tmp_dir=$(mktemp -d)
echo "Created temp directory: ${tmp_dir}"
tmp_zip="${tmp_dir}/devbox.zip"
echo "Downloading devbox from URL: $DEVBOX_USE_VERSION"
curl --fail --location --header "Authorization: Bearer ${{ github.token }}" --output "${tmp_zip}" "${DEVBOX_USE_VERSION}"
echo "Download complete, zip file size: $(ls -lh ${tmp_zip} | awk '{print $5}')"
echo "Extracting zip file to ${tmp_dir}"
unzip -q "${tmp_zip}" -d "${tmp_dir}"
echo "Extraction complete, contents of temp dir:"
ls -la "${tmp_dir}"
# Find the devbox binary in the extracted files
DEVBOX_BINARY=$(find "${tmp_dir}" -type f -name "devbox")
echo "Found devbox binary at: ${DEVBOX_BINARY}"
if [[ ! -f "${DEVBOX_BINARY}" ]]; then
echo "ERROR: Could not find devbox binary in downloaded archive"
exit 1
fi
mkdir -p ~/.local/bin
echo "Moving binary to ~/.local/bin/devbox"
mv "${DEVBOX_BINARY}" ~/.local/bin/devbox
chmod +x ~/.local/bin/devbox
echo "Binary permissions set, final location:"
ls -la ~/.local/bin/devbox
rm -rf "${tmp_dir}"
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
else
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
fi
else
tmp_file=$(mktemp)
latest_url="https://releases.jetify.com/devbox/stable/version"
Expand Down
Loading