Skip to content

Commit bcc4839

Browse files
committed
Allow url as devbox-version
1 parent 734088e commit bcc4839

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.github/workflows/test.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ jobs:
9494
sha256-checksum: '169836de22c41a1c68ac5a43e0514d4021137647c7c08ee8bd921faa430ee286'
9595
project-path: 'testdata'
9696
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"
97+
98+
99+
test-action-with-url-version:
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v4
103+
- name: Install devbox
104+
uses: ./
105+
with:
106+
devbox-version: http://nightly-ubuntu.dev-jetify.com/
107+
refresh-cli: true
108+
project-path: 'testdata'
109+
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

action.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
description: 'Specify whether the CLI should be redownloaded'
1616
default: 'false'
1717
devbox-version: # version of the devbox cli
18-
description: 'Specify devbox CLI version you want to pin to. Default to latest'
18+
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.'
1919
default: ''
2020
sha256-checksum: # the expected SHA256 checksum of the devbox binary.
2121
description: 'Specify an explicit checksum for the devbox binary. For extra security on top of the existing checks in the devbox launch script'
@@ -35,7 +35,27 @@ runs:
3535
DEVBOX_USE_VERSION: ${{ inputs.devbox-version }}
3636
run: |
3737
if [[ -n $DEVBOX_USE_VERSION ]]; then
38-
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
38+
if [[ "$DEVBOX_USE_VERSION" =~ ^https?:// ]]; then
39+
# If version is a URL, download and extract it
40+
tmp_dir=$(mktemp -d)
41+
tmp_zip="${tmp_dir}/devbox.zip"
42+
echo "Downloading devbox from URL: $DEVBOX_USE_VERSION"
43+
curl --fail --silent --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}"
44+
unzip -q "${tmp_zip}" -d "${tmp_dir}"
45+
# Find the devbox binary in the extracted files
46+
DEVBOX_BINARY=$(find "${tmp_dir}" -type f -name "devbox")
47+
if [[ ! -f "${DEVBOX_BINARY}" ]]; then
48+
echo "ERROR: Could not find devbox binary in downloaded archive"
49+
exit 1
50+
fi
51+
mkdir -p ~/.local/bin
52+
mv "${DEVBOX_BINARY}" ~/.local/bin/devbox
53+
chmod +x ~/.local/bin/devbox
54+
rm -rf "${tmp_dir}"
55+
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
56+
else
57+
echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV
58+
fi
3959
else
4060
tmp_file=$(mktemp)
4161
latest_url="https://releases.jetify.com/devbox/stable/version"

0 commit comments

Comments
 (0)