Skip to content

Commit 2f11abb

Browse files
authored
chore: migrate to hardened GHA runners and add JFrog PyPI proxy (#1384)
Switch all workflows to databricks-protected-runner-group with linux-ubuntu-latest-hardened labels. Add JFrog OIDC authentication via a reusable composite action and configure uv to use JFrog as PyPI proxy for workflows that install Python packages.
1 parent 2217be8 commit 2f11abb

File tree

6 files changed

+107
-10
lines changed

6 files changed

+107
-10
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Setup JFrog PyPI Proxy"
2+
description: "Authenticate with JFrog via OIDC and configure uv to use JFrog as PyPI proxy"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Get JFrog OIDC token
8+
shell: bash
9+
run: |
10+
set -euo pipefail
11+
12+
# Get GitHub OIDC ID token
13+
ID_TOKEN=$(curl -sLS \
14+
-H "User-Agent: actions/oidc-client" \
15+
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
16+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
17+
echo "::add-mask::${ID_TOKEN}"
18+
19+
# Exchange for JFrog access token
20+
ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \
21+
"https://databricks.jfrog.io/access/api/v1/oidc/token" \
22+
-d "{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"${ID_TOKEN}\", \"provider_name\": \"github-actions\"}" | jq .access_token | tr -d '"')
23+
echo "::add-mask::${ACCESS_TOKEN}"
24+
25+
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
26+
echo "FAIL: Could not extract JFrog access token"
27+
exit 1
28+
fi
29+
30+
echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV"
31+
echo "JFrog OIDC token obtained successfully"
32+
33+
- name: Configure pip and uv to use JFrog PyPI proxy
34+
shell: bash
35+
run: |
36+
set -euo pipefail
37+
JFROG_PYPI_URL="https://gha-service-account:${JFROG_ACCESS_TOKEN}@databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple"
38+
echo "PIP_INDEX_URL=${JFROG_PYPI_URL}" >> "$GITHUB_ENV"
39+
echo "UV_INDEX_URL=${JFROG_PYPI_URL}" >> "$GITHUB_ENV"
40+
41+
# Write pip.conf so subprocesses (hatch, pre-commit, virtualenv) also use JFrog
42+
mkdir -p ~/.config/pip
43+
cat > ~/.config/pip/pip.conf << EOF
44+
[global]
45+
index-url = ${JFROG_PYPI_URL}
46+
EOF
47+
48+
echo "pip and uv configured to use JFrog registry"

.github/workflows/ci-pr-linting.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ on:
1313

1414
jobs:
1515
pr-title:
16-
runs-on: linux-ubuntu-latest
16+
runs-on:
17+
group: databricks-protected-runner-group
18+
labels: linux-ubuntu-latest
1719
steps:
1820
- name: Validate PR title
1921
id: pr-format

.github/workflows/coverage.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ on:
1010
jobs:
1111
test:
1212
name: Run tests & display coverage
13-
runs-on: linux-ubuntu-latest
13+
runs-on:
14+
group: databricks-protected-runner-group
15+
labels: linux-ubuntu-latest
1416
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
1517
permissions:
1618
# Gives the action the necessary permissions for publishing new

.github/workflows/integration.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ on:
3535
required: false
3636
type: string
3737

38+
permissions:
39+
id-token: write
40+
contents: read
41+
3842
concurrency:
3943
group: ${{ github.workflow }}-${{ github.ref }}
4044
cancel-in-progress: true
4145

4246
jobs:
4347
run-uc-cluster-e2e-tests:
44-
runs-on: ubuntu-latest
48+
runs-on:
49+
group: databricks-protected-runner-group
50+
labels: linux-ubuntu-latest
4551
environment: azure-prod
4652
# Only run on internal PRs or manual dispatch - skip external forks to avoid secret access failures
4753
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
@@ -65,6 +71,10 @@ jobs:
6571
# Fetch enough history for PR testing
6672
fetch-depth: 0
6773

74+
- name: Setup JFrog PyPI Proxy
75+
uses: ./.github/actions/setup-jfrog-pypi
76+
77+
6878
- name: Set up python
6979
id: setup-python
7080
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
@@ -94,7 +104,9 @@ jobs:
94104
retention-days: 5
95105

96106
run-sqlwarehouse-e2e-tests:
97-
runs-on: ubuntu-latest
107+
runs-on:
108+
group: databricks-protected-runner-group
109+
labels: linux-ubuntu-latest
98110
environment: azure-prod
99111
# Only run on internal PRs or manual dispatch - skip external forks to avoid secret access failures
100112
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
@@ -119,6 +131,10 @@ jobs:
119131
# Fetch enough history for PR testing
120132
fetch-depth: 0
121133

134+
- name: Setup JFrog PyPI Proxy
135+
uses: ./.github/actions/setup-jfrog-pypi
136+
137+
122138
- name: Set up python
123139
id: setup-python
124140
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
@@ -148,7 +164,9 @@ jobs:
148164
retention-days: 5
149165

150166
run-cluster-e2e-tests:
151-
runs-on: ubuntu-latest
167+
runs-on:
168+
group: databricks-protected-runner-group
169+
labels: linux-ubuntu-latest
152170
environment: azure-prod
153171
# Only run on internal PRs or manual dispatch - skip external forks to avoid secret access failures
154172
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
@@ -171,6 +189,10 @@ jobs:
171189
# Fetch enough history for PR testing
172190
fetch-depth: 0
173191

192+
- name: Setup JFrog PyPI Proxy
193+
uses: ./.github/actions/setup-jfrog-pypi
194+
195+
174196
- name: Set up python
175197
id: setup-python
176198
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5

.github/workflows/main.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ on:
2929
- "**.md"
3030
workflow_dispatch:
3131

32-
permissions: read-all
32+
permissions:
33+
id-token: write
34+
contents: read
3335

3436
# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
3537
concurrency:
@@ -44,7 +46,9 @@ jobs:
4446
code-quality:
4547
name: Code Quality
4648

47-
runs-on: linux-ubuntu-latest
49+
runs-on:
50+
group: databricks-protected-runner-group
51+
labels: linux-ubuntu-latest
4852
timeout-minutes: 10
4953

5054
env:
@@ -57,6 +61,10 @@ jobs:
5761
- name: Check out the repository
5862
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5963

64+
- name: Setup JFrog PyPI Proxy
65+
uses: ./.github/actions/setup-jfrog-pypi
66+
67+
6068
- name: Set up Python
6169
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
6270
with:
@@ -74,10 +82,13 @@ jobs:
7482
unit:
7583
name: unit test / python ${{ matrix.python-version }}
7684

77-
runs-on: linux-ubuntu-latest
85+
runs-on:
86+
group: databricks-protected-runner-group
87+
labels: linux-ubuntu-latest
7888
timeout-minutes: 15
7989

8090
permissions:
91+
id-token: write
8192
# Gives the action the necessary permissions for publishing new
8293
# comments in pull requests.
8394
pull-requests: write
@@ -98,6 +109,10 @@ jobs:
98109
- name: Check out the repository
99110
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
100111

112+
- name: Setup JFrog PyPI Proxy
113+
uses: ./.github/actions/setup-jfrog-pypi
114+
115+
101116
- name: Set up Python ${{ matrix.python-version }}
102117
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
103118
with:
@@ -128,7 +143,9 @@ jobs:
128143

129144
build:
130145
name: Build and Verify Packages
131-
runs-on: linux-ubuntu-latest
146+
runs-on:
147+
group: databricks-protected-runner-group
148+
labels: linux-ubuntu-latest
132149

133150
env:
134151
UV_FROZEN: "1"
@@ -137,6 +154,10 @@ jobs:
137154
- name: Check out the repository
138155
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
139156

157+
- name: Setup JFrog PyPI Proxy
158+
uses: ./.github/actions/setup-jfrog-pypi
159+
160+
140161
- name: Set up Python
141162
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
142163
with:

.github/workflows/stale.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
- cron: "30 1 * * *"
55
jobs:
66
stale:
7-
runs-on: ubuntu-latest
7+
runs-on:
8+
group: databricks-protected-runner-group
9+
labels: linux-ubuntu-latest
810
steps:
911
# pinned at v4 (https://github.com/actions/stale/releases/tag/v4.0.0)
1012
- uses: actions/stale@cdf15f641adb27a71842045a94023bef6945e3aa

0 commit comments

Comments
 (0)