Skip to content

Commit 82497d1

Browse files
committed
Extract greenlight container tool install action
- Add greenlight-container-tools composite action installing jq, AWS CLI v2, and gh on demand for minimal container base images - Replace three inline apt/curl install steps in greenlight-pr-review.yml with calls to the new action (awscli; gh+jq; awscli+jq) - Each job now requests only the tools it needs via boolean inputs Notes: The ARC runners use a minimal node:20-bookworm container that lacks the CLI tools the GitHub-hosted ubuntu image ships by default, so each job hand-rolled the same apt/curl install boilerplate. Consolidating into one composite action removes the duplication and keeps the install logic single-sourced. Signed-off-by: Jean Schmidt <contato@jschmidt.me>
1 parent add7048 commit 82497d1

2 files changed

Lines changed: 71 additions & 31 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Greenlight container tools
2+
description: >-
3+
Installs CLI tools that the GitHub-hosted ubuntu image ships by default but a
4+
minimal container base image does not (jq, AWS CLI v2, GitHub CLI). Only the
5+
tools a job requests are installed. Assumes a Debian/Ubuntu base running as root.
6+
7+
inputs:
8+
jq:
9+
description: Install jq
10+
default: "false"
11+
awscli:
12+
description: Install AWS CLI v2
13+
default: "false"
14+
gh:
15+
description: Install the GitHub CLI (gh)
16+
default: "false"
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Install apt packages
22+
shell: bash
23+
env:
24+
INSTALL_JQ: ${{ inputs.jq }}
25+
INSTALL_AWSCLI: ${{ inputs.awscli }}
26+
run: |
27+
set -euo pipefail
28+
pkgs=(ca-certificates curl)
29+
if [ "$INSTALL_JQ" = "true" ]; then pkgs+=(jq); fi
30+
if [ "$INSTALL_AWSCLI" = "true" ]; then pkgs+=(unzip); fi
31+
apt-get update
32+
apt-get install -y --no-install-recommends "${pkgs[@]}"
33+
34+
- name: Install GitHub CLI
35+
if: ${{ inputs.gh == 'true' }}
36+
shell: bash
37+
run: |
38+
set -euo pipefail
39+
install -d -m 755 /etc/apt/keyrings
40+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
41+
-o /etc/apt/keyrings/githubcli-archive-keyring.gpg
42+
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
43+
arch="$(dpkg --print-architecture)"
44+
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
45+
> /etc/apt/sources.list.d/github-cli.list
46+
apt-get update
47+
apt-get install -y --no-install-recommends gh
48+
49+
- name: Install AWS CLI v2
50+
if: ${{ inputs.awscli == 'true' }}
51+
shell: bash
52+
run: |
53+
set -euo pipefail
54+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscliv2.zip
55+
unzip -q /tmp/awscliv2.zip -d /tmp
56+
/tmp/aws/install
57+
rm -rf /tmp/awscliv2.zip /tmp/aws

.github/workflows/greenlight-pr-review.yml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,10 @@ jobs:
6868
with:
6969
fetch-depth: 1
7070

71-
- name: Install AWS CLI v2
72-
run: |
73-
set -euo pipefail
74-
apt-get update
75-
apt-get install -y --no-install-recommends ca-certificates curl unzip
76-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscliv2.zip
77-
unzip -q /tmp/awscliv2.zip -d /tmp
78-
/tmp/aws/install
79-
rm -rf /tmp/awscliv2.zip /tmp/aws
71+
- name: Install container CLI tools
72+
uses: ./.github/actions/greenlight-container-tools
73+
with:
74+
awscli: "true"
8075

8176
- name: Set up Python 3.14
8277
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
@@ -148,19 +143,11 @@ jobs:
148143
path: pytorch
149144
fetch-depth: 1
150145

151-
- name: Install gh and jq
152-
run: |
153-
set -euo pipefail
154-
apt-get update
155-
apt-get install -y --no-install-recommends ca-certificates curl gnupg jq
156-
install -d -m 755 /etc/apt/keyrings
157-
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
158-
-o /etc/apt/keyrings/githubcli-archive-keyring.gpg
159-
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
160-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
161-
> /etc/apt/sources.list.d/github-cli.list
162-
apt-get update
163-
apt-get install -y --no-install-recommends gh
146+
- name: Install container CLI tools
147+
uses: ./.github/actions/greenlight-container-tools
148+
with:
149+
gh: "true"
150+
jq: "true"
164151

165152
- name: Configure AWS credentials via OIDC
166153
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
@@ -332,15 +319,11 @@ jobs:
332319
with:
333320
fetch-depth: 1
334321

335-
- name: Install AWS CLI v2 and jq
336-
run: |
337-
set -euo pipefail
338-
apt-get update
339-
apt-get install -y --no-install-recommends ca-certificates curl unzip jq
340-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscliv2.zip
341-
unzip -q /tmp/awscliv2.zip -d /tmp
342-
/tmp/aws/install
343-
rm -rf /tmp/awscliv2.zip /tmp/aws
322+
- name: Install container CLI tools
323+
uses: ./.github/actions/greenlight-container-tools
324+
with:
325+
awscli: "true"
326+
jq: "true"
344327

345328
- name: Set up Python 3.14
346329
# greenlight pins requires-python >=3.14 with uv python-preference=only-system,

0 commit comments

Comments
 (0)