Skip to content

Commit 15158b8

Browse files
authored
[BRE-831] migrate secrets AKV (#91)
1 parent 7420251 commit 15158b8

File tree

4 files changed

+86
-15
lines changed

4 files changed

+86
-15
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
build-docker:
88
name: Build Docker images
99
runs-on: ubuntu-22.04
10+
permissions:
11+
contents: read
12+
id-token: write
1013
env:
1114
_AZ_REGISTRY: bitwardenprod.azurecr.io
1215
_PROJECT_NAME: sm-operator
@@ -22,9 +25,11 @@ jobs:
2225
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
2326

2427
- name: Log in to Azure
25-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
28+
uses: bitwarden/gh-actions/azure-login@main
2629
with:
27-
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
30+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
31+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
32+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
2833

2934
- name: Log in to ACR
3035
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
@@ -105,3 +110,6 @@ jobs:
105110
run: |
106111
make undeploy
107112
kind delete cluster
113+
114+
- name: Log out from Azure
115+
uses: bitwarden/gh-actions/azure-logout@main

.github/workflows/bump-version.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ jobs:
1515
permissions:
1616
contents: write
1717
pull-requests: write
18+
id-token: write
1819

1920
steps:
2021
- name: Check out repo
2122
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
2223

2324
- name: Log in to Azure
24-
uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1
25+
uses: bitwarden/gh-actions/azure-login@main
2526
with:
26-
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
27+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
28+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
29+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
2730

2831
- name: Retrieve secrets
2932
id: retrieve-secrets
@@ -32,6 +35,9 @@ jobs:
3235
keyvault: "bitwarden-ci"
3336
secrets: "github-gpg-private-key, github-gpg-private-key-passphrase"
3437

38+
- name: Log out from Azure
39+
uses: bitwarden/gh-actions/azure-logout@main
40+
3541
- name: Import GPG key
3642
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
3743
with:

.github/workflows/release.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ on:
1616
jobs:
1717
setup:
1818
name: Setup
19+
permissions:
20+
contents: read
1921
runs-on: ubuntu-22.04
2022
outputs:
2123
release_version: ${{ steps.version.outputs.version }}
@@ -51,6 +53,8 @@ jobs:
5153
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
5254
runs-on: ubuntu-22.04
5355
needs: setup
56+
permissions:
57+
contents: write
5458
steps:
5559
- name: Create release
5660
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
@@ -68,6 +72,9 @@ jobs:
6872
needs:
6973
- setup
7074
- release-github
75+
permissions:
76+
contents: read
77+
id-token: write
7178
env:
7279
_AZ_REGISTRY: bitwardenprod.azurecr.io
7380
_PROJECT_NAME: sm-operator
@@ -84,10 +91,12 @@ jobs:
8491
echo "GitHub event: $GITHUB_EVENT"
8592
echo "Github Release Option: $_RELEASE_OPTION"
8693
87-
- name: Login to Azure - Prod Subscription
88-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
94+
- name: Log in to Azure
95+
uses: bitwarden/gh-actions/azure-login@main
8996
with:
90-
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
97+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
98+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
99+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
91100

92101
- name: Log in to Azure ACR
93102
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
@@ -96,7 +105,6 @@ jobs:
96105
id: setup-dct
97106
uses: bitwarden/gh-actions/setup-docker-trust@main
98107
with:
99-
azure-creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
100108
azure-keyvault-name: "bitwarden-ci"
101109

102110
- name: Pull image
@@ -137,6 +145,9 @@ jobs:
137145
- name: Log out of Docker
138146
run: docker logout
139147

148+
- name: Log out from Azure
149+
uses: bitwarden/gh-actions/azure-logout@main
150+
140151
check-failures:
141152
name: Check for failures
142153
if: always()
@@ -145,18 +156,22 @@ jobs:
145156
- release-docker
146157
- release-github
147158
- setup
159+
permissions:
160+
id-token: write
148161
steps:
149162
- name: Check if any job failed
150163
if: |
151164
github.ref == 'refs/heads/main'
152165
&& contains(needs.*.result, 'failure')
153166
run: exit 1
154167

155-
- name: Login to Azure - CI subscription
156-
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
168+
- name: Log in to Azure
157169
if: failure()
170+
uses: bitwarden/gh-actions/azure-login@main
158171
with:
159-
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
172+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
173+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
174+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
160175

161176
- name: Retrieve secrets
162177
id: retrieve-secrets
@@ -166,6 +181,10 @@ jobs:
166181
keyvault: "bitwarden-ci"
167182
secrets: "devops-alerts-slack-webhook-url"
168183

184+
- name: Log out from Azure
185+
if: failure()
186+
uses: bitwarden/gh-actions/azure-logout@main
187+
169188
- name: Notify Slack on failure
170189
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
171190
if: failure()

.github/workflows/scan.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
check-run:
1616
name: Check PR run
1717
uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main
18+
permissions:
19+
contents: read
1820

1921
sast:
2022
name: SAST scan
@@ -24,23 +26,41 @@ jobs:
2426
contents: read
2527
pull-requests: write
2628
security-events: write
29+
id-token: write
2730

2831
steps:
2932
- name: Check out repo
3033
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3134
with:
3235
ref: ${{ github.event.pull_request.head.sha }}
3336

37+
- name: Log in to Azure
38+
uses: bitwarden/gh-actions/azure-login@main
39+
with:
40+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
41+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
42+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
43+
44+
- name: Get Azure Key Vault secrets
45+
id: get-kv-secrets
46+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
47+
with:
48+
keyvault: gh-org-bitwarden
49+
secrets: "CHECKMARX-TENANT,CHECKMARX-CLIENT-ID,CHECKMARX-SECRET"
50+
51+
- name: Log out from Azure
52+
uses: bitwarden/gh-actions/azure-logout@main
53+
3454
- name: Scan with Checkmarx
3555
uses: checkmarx/ast-github-action@9fda4ab4c1b67c35de380552a972a82997d97731 # 2.0.42
3656
env:
3757
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
3858
with:
3959
project_name: ${{ github.repository }}
40-
cx_tenant: ${{ secrets.CHECKMARX_TENANT }}
60+
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
4161
base_uri: https://ast.checkmarx.net/
42-
cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }}
43-
cx_client_secret: ${{ secrets.CHECKMARX_SECRET }}
62+
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
63+
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
4464
additional_params: |
4565
--report-format sarif \
4666
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
@@ -60,6 +80,7 @@ jobs:
6080
permissions:
6181
contents: read
6282
pull-requests: write
83+
id-token: write
6384

6485
steps:
6586
- name: Check out repo
@@ -68,10 +89,27 @@ jobs:
6889
fetch-depth: 0
6990
ref: ${{ github.event.pull_request.head.sha }}
7091

92+
- name: Log in to Azure
93+
uses: bitwarden/gh-actions/azure-login@main
94+
with:
95+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
96+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
97+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
98+
99+
- name: Get Azure Key Vault secrets
100+
id: get-kv-secrets
101+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
102+
with:
103+
keyvault: gh-org-bitwarden
104+
secrets: "SONAR-TOKEN"
105+
106+
- name: Log out from Azure
107+
uses: bitwarden/gh-actions/azure-logout@main
108+
71109
- name: Scan with SonarCloud
72110
uses: sonarsource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97 # v5.1.0
73111
env:
74-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
112+
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
75113
with:
76114
args: >
77115
-Dsonar.organization=${{ github.repository_owner }}

0 commit comments

Comments
 (0)