Skip to content

Commit 73b935c

Browse files
authored
[BRE-831] migrate secrets AKV (#124)
1 parent d7f37a1 commit 73b935c

2 files changed

Lines changed: 62 additions & 8 deletions

File tree

.github/workflows/cd.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
permissions:
1010
contents: read
1111
packages: write
12+
id-token: write
1213
steps:
1314
- name: Check out repo
1415
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -48,11 +49,28 @@ jobs:
4849
exit 1
4950
fi
5051

52+
- name: Log in to Azure
53+
uses: bitwarden/gh-actions/azure-login@main
54+
with:
55+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
56+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
57+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
58+
59+
- name: Get Azure Key Vault secrets
60+
id: get-kv-secrets
61+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
62+
with:
63+
keyvault: gh-passwordless-java
64+
secrets: "GPG-KEY,GPG-PASSPHRASE,OSSRH-USERNAME,OSSRH-TOKEN"
65+
66+
- name: Log out from Azure
67+
uses: bitwarden/gh-actions/azure-logout@main
68+
5169
- id: install-secret-key
5270
name: Import GPG Secret Key
5371
run: |
5472
# Install gpg secret key
55-
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
73+
cat <(echo -e "${{ steps.get-kv-secrets.outputs.GPG-KEY }}") | gpg --batch --import
5674
5775
# Verify gpg secret key
5876
gpg --list-secret-keys --keyid-format LONG
@@ -62,8 +80,8 @@ jobs:
6280
mvn \
6381
--batch-mode \
6482
-Dmaven.test.skip \
65-
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
83+
-Dgpg.passphrase=${{ steps.get-kv-secrets.outputs.GPG-PASSPHRASE }} \
6684
clean deploy
6785
env:
68-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
69-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
86+
MAVEN_USERNAME: ${{ steps.get-kv-secrets.outputs.OSSRH-USERNAME }}
87+
MAVEN_PASSWORD: ${{ steps.get-kv-secrets.outputs.OSSRH-TOKEN }}

.github/workflows/scan.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,41 @@ jobs:
3333
contents: read
3434
pull-requests: write
3535
security-events: write
36+
id-token: write
3637

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

44+
- name: Log in to Azure
45+
uses: bitwarden/gh-actions/azure-login@main
46+
with:
47+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
48+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
49+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
50+
51+
- name: Get Azure Key Vault secrets
52+
id: get-kv-secrets
53+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
54+
with:
55+
keyvault: gh-org-bitwarden
56+
secrets: "CHECKMARX-TENANT,CHECKMARX-CLIENT-ID,CHECKMARX-SECRET"
57+
58+
- name: Log out from Azure
59+
uses: bitwarden/gh-actions/azure-logout@main
60+
4361
- name: Scan with Checkmarx
4462
uses: checkmarx/ast-github-action@629a9fac14369bf2898d583b22bf8c40a5caf8e9 # 2.0.40
4563
env:
4664
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
4765
with:
4866
project_name: ${{ github.repository }}
49-
cx_tenant: ${{ secrets.CHECKMARX_TENANT }}
67+
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
5068
base_uri: https://ast.checkmarx.net/
51-
cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }}
52-
cx_client_secret: ${{ secrets.CHECKMARX_SECRET }}
69+
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
70+
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
5371
additional_params: |
5472
--report-format sarif \
5573
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
@@ -69,6 +87,7 @@ jobs:
6987
permissions:
7088
contents: read
7189
pull-requests: write
90+
id-token: write
7291

7392
steps:
7493
- name: Check out repo
@@ -83,8 +102,25 @@ jobs:
83102
java-version: 17
84103
distribution: "temurin"
85104

105+
- name: Log in to Azure
106+
uses: bitwarden/gh-actions/azure-login@main
107+
with:
108+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
109+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
110+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
111+
112+
- name: Get Azure Key Vault secrets
113+
id: get-kv-secrets
114+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
115+
with:
116+
keyvault: gh-org-bitwarden
117+
secrets: "SONAR-TOKEN"
118+
119+
- name: Log out from Azure
120+
uses: bitwarden/gh-actions/azure-logout@main
121+
86122
- name: Scan with SonarCloud
87123
env:
88-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
124+
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
89125
run: mvn clean install -Dgpg.skip=true sonar:sonar ${{ contains(github.event_name, 'pull_request') && format('-Dsonar.pullrequest.key={0}', github.event.pull_request.number) || '' }}
90126

0 commit comments

Comments
 (0)