Skip to content

Commit 13b5574

Browse files
pixman20vincentsalucci
authored andcommitted
[BRE-831] migrate secrets AKV (#796)
1 parent a35d921 commit 13b5574

File tree

4 files changed

+123
-19
lines changed

4 files changed

+123
-19
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
cloc:
1717
name: CLOC
1818
runs-on: ubuntu-24.04
19+
permissions:
20+
contents: read
1921
steps:
2022
- name: Checkout repo
2123
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -32,6 +34,8 @@ jobs:
3234
setup:
3335
name: Setup
3436
runs-on: ubuntu-24.04
37+
permissions:
38+
contents: read
3539
outputs:
3640
package_version: ${{ steps.retrieve-version.outputs.package_version }}
3741
steps:
@@ -53,6 +57,8 @@ jobs:
5357
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
5458
_PKG_FETCH_NODE_VERSION: 18.5.0
5559
_PKG_FETCH_VERSION: 3.4
60+
permissions:
61+
contents: read
5662
steps:
5763
- name: Checkout repo
5864
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -132,6 +138,8 @@ jobs:
132138
name: Build Mac CLI
133139
runs-on: macos-13
134140
needs: setup
141+
permissions:
142+
contents: read
135143
env:
136144
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
137145
_PKG_FETCH_NODE_VERSION: 18.5.0
@@ -208,6 +216,8 @@ jobs:
208216
name: Build Windows CLI
209217
runs-on: windows-2022
210218
needs: setup
219+
permissions:
220+
contents: read
211221
env:
212222
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
213223
_WIN_PKG_FETCH_VERSION: 18.5.0
@@ -341,6 +351,9 @@ jobs:
341351
name: Build Windows GUI
342352
runs-on: windows-2022
343353
needs: setup
354+
permissions:
355+
contents: read
356+
id-token: write
344357
env:
345358
NODE_OPTIONS: --max_old_space_size=4096
346359
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
@@ -372,10 +385,12 @@ jobs:
372385
- name: Install Node dependencies
373386
run: npm install
374387

375-
- name: Login to Azure
376-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
388+
- name: Log in to Azure
389+
uses: bitwarden/gh-actions/azure-login@main
377390
with:
378-
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
391+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
392+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
393+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
379394

380395
- name: Retrieve secrets
381396
id: retrieve-secrets
@@ -388,6 +403,9 @@ jobs:
388403
code-signing-client-secret,
389404
code-signing-cert-name"
390405

406+
- name: Log out from Azure
407+
uses: bitwarden/gh-actions/azure-logout@main
408+
391409
- name: Build & Sign
392410
run: npm run dist:win
393411
env:
@@ -431,6 +449,8 @@ jobs:
431449
name: Build Linux GUI
432450
runs-on: ubuntu-24.04
433451
needs: setup
452+
permissions:
453+
contents: read
434454
env:
435455
NODE_OPTIONS: --max_old_space_size=4096
436456
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
@@ -485,6 +505,9 @@ jobs:
485505
name: Build MacOS GUI
486506
runs-on: macos-13
487507
needs: setup
508+
permissions:
509+
contents: read
510+
id-token: write
488511
env:
489512
NODE_OPTIONS: --max_old_space_size=4096
490513
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
@@ -512,10 +535,19 @@ jobs:
512535
echo "GitHub ref: $GITHUB_REF"
513536
echo "GitHub event: $GITHUB_EVENT"
514537
515-
- name: Login to Azure
516-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
538+
- name: Log in to Azure
539+
uses: bitwarden/gh-actions/azure-login@main
540+
with:
541+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
542+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
543+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
544+
545+
- name: Get Azure Key Vault secrets
546+
id: get-kv-secrets
547+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
517548
with:
518-
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
549+
keyvault: gh-directory-connector
550+
secrets: "KEYCHAIN-PASSWORD,APP-STORE-CONNECT-AUTH-KEY,APP-STORE-CONNECT-TEAM-ISSUER"
519551

520552
- name: Get certificates
521553
run: |
@@ -530,9 +562,12 @@ jobs:
530562
az keyvault secret show --id https://bitwarden-ci.vault.azure.net/certificates/macdev-cert |
531563
jq -r .value | base64 -d > $HOME/certificates/macdev-cert.p12
532564
565+
- name: Log out from Azure
566+
uses: bitwarden/gh-actions/azure-logout@main
567+
533568
- name: Set up keychain
534569
env:
535-
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
570+
KEYCHAIN_PASSWORD: ${{ steps.get-kv-secrets.outputs.KEYCHAIN-PASSWORD }}
536571
run: |
537572
security create-keychain -p $KEYCHAIN_PASSWORD build.keychain
538573
security default-keychain -s build.keychain
@@ -566,13 +601,13 @@ jobs:
566601
run: |
567602
mkdir ~/private_keys
568603
cat << EOF > ~/private_keys/AuthKey_UFD296548T.p8
569-
${{ secrets.APP_STORE_CONNECT_AUTH_KEY }}
604+
${{ steps.get-kv-secrets.outputs.APP-STORE-CONNECT-AUTH-KEY }}
570605
EOF
571606
572607
- name: Build application
573608
run: npm run dist:mac
574609
env:
575-
APP_STORE_CONNECT_TEAM_ISSUER: ${{ secrets.APP_STORE_CONNECT_TEAM_ISSUER }}
610+
APP_STORE_CONNECT_TEAM_ISSUER: ${{ steps.get-kv-secrets.outputs.APP-STORE-CONNECT-TEAM-ISSUER }}
576611
APP_STORE_CONNECT_AUTH_KEY: UFD296548T
577612
APP_STORE_CONNECT_AUTH_KEY_PATH: ~/private_keys/AuthKey_UFD296548T.p8
578613
CSC_FOR_PULL_REQUEST: true
@@ -618,6 +653,8 @@ jobs:
618653
- windows-gui
619654
- linux-gui
620655
- macos-gui
656+
permissions:
657+
id-token: write
621658
steps:
622659
- name: Check if any job failed
623660
if: |
@@ -627,11 +664,13 @@ jobs:
627664
&& contains(needs.*.result, 'failure')
628665
run: exit 1
629666

630-
- name: Login to Azure - CI subscription
631-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
667+
- name: Log in to Azure
632668
if: failure()
669+
uses: bitwarden/gh-actions/azure-login@main
633670
with:
634-
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
671+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
672+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
673+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
635674

636675
- name: Retrieve secrets
637676
id: retrieve-secrets
@@ -641,6 +680,9 @@ jobs:
641680
keyvault: "bitwarden-ci"
642681
secrets: "devops-alerts-slack-webhook-url"
643682

683+
- name: Log out from Azure
684+
uses: bitwarden/gh-actions/azure-logout@main
685+
644686
- name: Notify Slack on failure
645687
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
646688
if: failure()

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
setup:
2121
name: Setup
2222
runs-on: ubuntu-24.04
23+
permissions:
24+
contents: read
2325
outputs:
2426
release_version: ${{ steps.version.outputs.version }}
2527
steps:
@@ -48,6 +50,10 @@ jobs:
4850
name: Release
4951
runs-on: ubuntu-24.04
5052
needs: setup
53+
permissions:
54+
actions: read
55+
packages: read
56+
contents: write
5157
steps:
5258
- name: Download all artifacts
5359
if: ${{ inputs.release_type != 'Dry Run' }}

.github/workflows/scan.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
pull_request_target:
1313
types: [opened, synchronize, reopened]
1414
branches:
15-
- "main"
15+
- main
1616

1717
permissions: {}
1818

@@ -31,23 +31,41 @@ jobs:
3131
contents: read
3232
pull-requests: write
3333
security-events: write
34+
id-token: write
3435

3536
steps:
3637
- name: Check out repo
3738
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3839
with:
3940
ref: ${{ github.event.pull_request.head.sha }}
4041

42+
- name: Log in to Azure
43+
uses: bitwarden/gh-actions/azure-login@main
44+
with:
45+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
46+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
47+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
48+
49+
- name: Get Azure Key Vault secrets
50+
id: get-kv-secrets
51+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
52+
with:
53+
keyvault: gh-org-bitwarden
54+
secrets: "CHECKMARX-TENANT,CHECKMARX-CLIENT-ID,CHECKMARX-SECRET"
55+
56+
- name: Log out from Azure
57+
uses: bitwarden/gh-actions/azure-logout@main
58+
4159
- name: Scan with Checkmarx
4260
uses: checkmarx/ast-github-action@184bf2f64f55d1c93fd6636d539edf274703e434 # 2.0.41
4361
env:
4462
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
4563
with:
4664
project_name: ${{ github.repository }}
47-
cx_tenant: ${{ secrets.CHECKMARX_TENANT }}
65+
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
4866
base_uri: https://ast.checkmarx.net/
49-
cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }}
50-
cx_client_secret: ${{ secrets.CHECKMARX_SECRET }}
67+
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
68+
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
5169
additional_params: |
5270
--report-format sarif \
5371
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
@@ -67,6 +85,7 @@ jobs:
6785
permissions:
6886
contents: read
6987
pull-requests: write
88+
id-token: write
7089

7190
steps:
7291
- name: Check out repo
@@ -75,10 +94,27 @@ jobs:
7594
fetch-depth: 0
7695
ref: ${{ github.event.pull_request.head.sha }}
7796

97+
- name: Log in to Azure
98+
uses: bitwarden/gh-actions/azure-login@main
99+
with:
100+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
101+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
102+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
103+
104+
- name: Get Azure Key Vault secrets
105+
id: get-kv-secrets
106+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
107+
with:
108+
keyvault: gh-org-bitwarden
109+
secrets: "SONAR-TOKEN"
110+
111+
- name: Log out from Azure
112+
uses: bitwarden/gh-actions/azure-logout@main
113+
78114
- name: Scan with SonarCloud
79115
uses: sonarsource/sonarqube-scan-action@2500896589ef8f7247069a56136f8dc177c27ccf # v5.2.0
80116
env:
81-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
117+
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
82118
with:
83119
args: >
84120
-Dsonar.organization=${{ github.repository_owner }}

.github/workflows/version-bump.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,39 @@ jobs:
1212
bump_version:
1313
name: Bump Version
1414
runs-on: ubuntu-24.04
15+
permissions:
16+
contents: write
17+
id-token: write
1518
steps:
1619
- name: Validate version input
1720
if: ${{ inputs.version_number_override != '' }}
1821
uses: bitwarden/gh-actions/version-check@main
1922
with:
2023
version: ${{ inputs.version_number_override }}
2124

25+
- name: Log in to Azure
26+
uses: bitwarden/gh-actions/azure-login@main
27+
with:
28+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
29+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
30+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
31+
32+
- name: Get Azure Key Vault secrets
33+
id: get-kv-secrets
34+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
35+
with:
36+
keyvault: gh-org-bitwarden
37+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
38+
39+
- name: Log out from Azure
40+
uses: bitwarden/gh-actions/azure-logout@main
41+
2242
- name: Generate GH App token
2343
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
2444
id: app-token
2545
with:
26-
app-id: ${{ secrets.BW_GHAPP_ID }}
27-
private-key: ${{ secrets.BW_GHAPP_KEY }}
46+
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
47+
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
2848

2949
- name: Checkout Branch
3050
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

0 commit comments

Comments
 (0)