Skip to content

Commit 5e876b9

Browse files
meysholdtona-agent
andcommitted
Add gh CLI setup command step to both automations
Installs gh if missing, authenticates via git credential helper token. Co-authored-by: Ona <no-reply@ona.com>
1 parent 171423d commit 5e876b9

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

.ona/fix-codescan-alert.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ action:
1111
maxParallel: 1
1212
maxTotal: 10
1313
steps:
14+
- task:
15+
command: |
16+
set -e
17+
if ! command -v gh &>/dev/null; then
18+
echo "Installing GitHub CLI..."
19+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
20+
sudo mkdir -p -m 755 /etc/apt/keyrings
21+
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
22+
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
23+
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
24+
sudo apt update && sudo apt install gh -y
25+
fi
26+
echo "gh version: $(gh --version | head -1)"
27+
TOKEN=$(git credential fill <<EOF | grep password | cut -d= -f2
28+
protocol=https
29+
host=github.com
30+
31+
EOF
32+
)
33+
echo "$TOKEN" | gh auth login --with-token
34+
gh auth status
1435
- agent:
1536
prompt: |
1637
Query the GitHub code scanning alerts for this repository using the GitHub CLI:

.ona/fix-dependabot-alert.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ action:
1111
maxParallel: 1
1212
maxTotal: 10
1313
steps:
14+
- task:
15+
command: |
16+
set -e
17+
if ! command -v gh &>/dev/null; then
18+
echo "Installing GitHub CLI..."
19+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
20+
sudo mkdir -p -m 755 /etc/apt/keyrings
21+
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
22+
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
23+
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
24+
sudo apt update && sudo apt install gh -y
25+
fi
26+
echo "gh version: $(gh --version | head -1)"
27+
TOKEN=$(git credential fill <<EOF | grep password | cut -d= -f2
28+
protocol=https
29+
host=github.com
30+
31+
EOF
32+
)
33+
echo "$TOKEN" | gh auth login --with-token
34+
gh auth status
1435
- agent:
1536
prompt: |
1637
Query the GitHub Dependabot alerts for this repository using the GitHub CLI:

0 commit comments

Comments
 (0)