Skip to content

Commit 28e4ff6

Browse files
meysholdtona-agent
andcommitted
Simplify gh install: download binary tarball instead of apt
Co-authored-by: Ona <no-reply@ona.com>
1 parent 0dcdf48 commit 28e4ff6

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

.ona/fix-codescan-alert.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ action:
1919
exit 0
2020
fi
2121
echo "Installing GitHub CLI..."
22-
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
23-
sudo mkdir -p -m 755 /etc/apt/keyrings
24-
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
25-
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
26-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
27-
sudo apt update && sudo apt install gh -y
22+
GH_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep -oP '"tag_name":\s*"v\K[^"]+')
23+
curl -sL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" | tar xz -C /tmp
24+
sudo mv "/tmp/gh_${GH_VERSION}_linux_amd64/bin/gh" /usr/local/bin/gh
25+
rm -rf "/tmp/gh_${GH_VERSION}_linux_amd64"
2826
echo "gh version: $(gh --version | head -1)"
2927
- task:
3028
command: |

.ona/fix-dependabot-alert.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ action:
1919
exit 0
2020
fi
2121
echo "Installing GitHub CLI..."
22-
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
23-
sudo mkdir -p -m 755 /etc/apt/keyrings
24-
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
25-
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
26-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
27-
sudo apt update && sudo apt install gh -y
22+
GH_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep -oP '"tag_name":\s*"v\K[^"]+')
23+
curl -sL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" | tar xz -C /tmp
24+
sudo mv "/tmp/gh_${GH_VERSION}_linux_amd64/bin/gh" /usr/local/bin/gh
25+
rm -rf "/tmp/gh_${GH_VERSION}_linux_amd64"
2826
echo "gh version: $(gh --version | head -1)"
2927
- task:
3028
command: |

0 commit comments

Comments
 (0)