Skip to content

Commit 69f901c

Browse files
authored
ci: migrate to hardened runners, disable publish during freeze (#353)
* ci: migrate to hardened runners, disable publish during freeze Switch all 7 workflow jobs from `ubuntu-latest` to the `databricks-protected-runner-group` hardened runner group per go/hardened-gha step 3. Disable the release publish job during the release freeze per go/hardened-gha step 7. The build job remains active for validation. A clear comment marks when and how to re-enable. Fix `.npmrc` from `package-lock=false` to `package-lock=true` so local dev keeps the lockfile in sync with `npm ci` in CI. Co-authored-by: Isaac * ci: add JFrog Artifactory proxy for npm registry access Hardened runners block direct access to public registries. Configure JFrog Artifactory as an npm proxy using OIDC token exchange per the remote registry access guidance. Added to all jobs that run `npm ci`: lint, unit-test, e2e-test (main.yml) and build (release.yml). The coverage job and dco-check workflow do not access npm and are left unchanged. Adds `id-token: write` permission for the OIDC token exchange. Co-authored-by: Isaac * ci: add setup-node to lint and e2e-test jobs Hardened runners may not have Node.js pre-installed (reported in #unblock-github-action-for-eng). Add explicit setup-node step to the lint and e2e-test jobs which run npm commands but previously relied on the runner having Node available. The unit-test and release build jobs already have setup-node. The coverage and dco-check jobs don't run npm commands and don't need it. Co-authored-by: Isaac * ci: revert .npmrc change (moved to separate PR) Co-authored-by: Isaac * ci: extract JFrog OIDC setup into reusable composite action Move the duplicated JFrog OIDC token exchange and npm registry configuration into .github/actions/setup-jfrog/action.yml, replacing three identical ~27-line blocks in lint, unit-test, and e2e-test jobs with a single `uses: ./.github/actions/setup-jfrog` step. Follows the pattern from databricks/databricks-sqlalchemy#59. Co-authored-by: Isaac
1 parent 0781ad8 commit 69f901c

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Setup JFrog OIDC
2+
description: Obtain a JFrog access token via GitHub OIDC and configure npm to use JFrog registry 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+
ID_TOKEN=$(curl -sLS \
12+
-H "User-Agent: actions/oidc-client" \
13+
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
14+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
15+
echo "::add-mask::${ID_TOKEN}"
16+
ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \
17+
"https://databricks.jfrog.io/access/api/v1/oidc/token" \
18+
-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 '"')
19+
echo "::add-mask::${ACCESS_TOKEN}"
20+
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
21+
echo "FAIL: Could not extract JFrog access token"
22+
exit 1
23+
fi
24+
echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV"
25+
echo "JFrog OIDC token obtained successfully"
26+
27+
- name: Configure npm for JFrog
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
cat > ~/.npmrc << EOF
32+
registry=https://databricks.jfrog.io/artifactory/api/npm/db-npm/
33+
//databricks.jfrog.io/artifactory/api/npm/db-npm/:_authToken=${JFROG_ACCESS_TOKEN}
34+
always-auth=true
35+
EOF
36+
echo "npm configured to use JFrog registry"

.github/workflows/dco-check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ permissions:
88

99
jobs:
1010
check:
11-
runs-on: ubuntu-latest
11+
runs-on:
12+
group: databricks-protected-runner-group
13+
labels: linux-ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1416
with:

.github/workflows/main.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ on:
1010

1111
permissions:
1212
contents: read
13+
id-token: write
1314

1415
jobs:
1516
lint:
16-
runs-on: ubuntu-latest
17+
runs-on:
18+
group: databricks-protected-runner-group
19+
labels: linux-ubuntu-latest
1720
steps:
1821
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
22+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
23+
with:
24+
node-version: 20
25+
- uses: ./.github/actions/setup-jfrog
1926
- name: Cache node modules
2027
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
2128
env:
@@ -34,7 +41,9 @@ jobs:
3441
npm run lint
3542
3643
unit-test:
37-
runs-on: ubuntu-latest
44+
runs-on:
45+
group: databricks-protected-runner-group
46+
labels: linux-ubuntu-latest
3847
strategy:
3948
matrix:
4049
# only LTS versions starting from the lowest we support
@@ -53,6 +62,7 @@ jobs:
5362
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
5463
with:
5564
python-version: '3.10'
65+
- uses: ./.github/actions/setup-jfrog
5666
- name: Cache node modules
5767
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
5868
with:
@@ -75,7 +85,9 @@ jobs:
7585
retention-days: 1
7686

7787
e2e-test:
78-
runs-on: ubuntu-latest
88+
runs-on:
89+
group: databricks-protected-runner-group
90+
labels: linux-ubuntu-latest
7991
environment: azure-prod
8092
env:
8193
E2E_HOST: ${{ secrets.DATABRICKS_HOST }}
@@ -90,6 +102,10 @@ jobs:
90102

91103
steps:
92104
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
105+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
106+
with:
107+
node-version: 20
108+
- uses: ./.github/actions/setup-jfrog
93109
- name: Cache node modules
94110
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
95111
with:
@@ -113,7 +129,9 @@ jobs:
113129

114130
coverage:
115131
needs: [unit-test, e2e-test]
116-
runs-on: ubuntu-latest
132+
runs-on:
133+
group: databricks-protected-runner-group
134+
labels: linux-ubuntu-latest
117135
env:
118136
cache-name: cache-node-modules
119137

0 commit comments

Comments
 (0)