Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 034ecc7

Browse files
Godintomverin
andauthored
BUILD-2179 Use Vault
Co-authored-by: Tom <[email protected]>
1 parent 1f7fa25 commit 034ecc7

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

.cirrus.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
gcp_credentials: ENCRYPTED[!149d4005ecdba4cdd78bb5ba22756ebb98bf8e3367ee2e9ab08c5a1608c0d3e3b501904b67a1d67c0b63085e469d7dde!]
22

33
env:
4-
GITHUB_TOKEN: ENCRYPTED[!f458126aa9ed2ac526f220c5acb51dd9cc255726b34761a56fc78d4294c11089502a882888cef0ca7dd4085e72e611a5!]
5-
SONAR_TOKEN: ENCRYPTED[!4e5894b7b32f763db69e70fb56188d3f42539db36374b1f97c425f37a7ecd441c28a9da267c461b9cc8fb53124f14c22!]
6-
REPOX_CLI_CONFIG_QA_DEPLOYER: ENCRYPTED[!07d065a3727e6f270943618078b68718ff229941f1133c92e587f8e258c086f50f61a75f99496a8b2d7045da177b3ad1!]
7-
REPOX_CLI_CONFIG_BUILD_PROMOTER: ENCRYPTED[!a4c9e5455d42b4395387b7489c47bb4c70e85cae5641b77b3b7e53b68ae57bc7b2e591ca4dd640138e15551f2915b08f!]
4+
CIRRUS_VAULT_URL: https://vault.sonar.build:8200
5+
CIRRUS_VAULT_AUTH_PATH: jwt-cirrusci
6+
CIRRUS_VAULT_ROLE: cirrusci-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}
7+
8+
SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
9+
ARTIFACTORY_URL: https://repox.jfrog.io/
10+
ARTIFACTORY_DEPLOY_ACCESS_TOKEN : VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
11+
ARTIFACTORY_PROMOTE_ACCESS_TOKEN : VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
812
# Use bash (instead of sh on linux or cmd.exe on windows)
913
CIRRUS_SHELL: bash
1014

@@ -33,9 +37,9 @@ build_task:
3337
CIRRUS_CLONE_DEPTH: 10
3438
SONARSOURCE_QA: true
3539
script:
36-
- jfrog config import $REPOX_CLI_CONFIG_QA_DEPLOYER
40+
- jfrog config add repox --url $ARTIFACTORY_URL --access-token $ARTIFACTORY_DEPLOY_ACCESS_TOKEN
3741
- jfrog rt npm-config --repo-resolve npm --repo-deploy sonarsource-npm-public-qa
38-
- init_git_submodules -r
42+
- git submodule update --init --depth 1 -r
3943
- jfrog rt npm-ci
4044
- npm run typecheck
4145
- npm run build
@@ -56,7 +60,7 @@ ws_scan_task:
5660
# run only on master and long-term branches
5761
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*")
5862
env:
59-
WS_APIKEY: ENCRYPTED[!3929c6148b9dfc751a2d17c590b15d755f82cd9c108f2de5f24a5b32f2a0c26144e921fab7e2c959fc2824d6d6d1550d!]
63+
WS_APIKEY: VAULT[development/kv/data/mend data.apikey]
6064
maven_cache:
6165
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
6266
whitesource_script:

.github/workflows/release.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
on:
1+
on:
22
release:
33
types:
44
- published
55

6-
jobs:
6+
jobs:
77
publish:
88
runs-on: ubuntu-latest
99
env:
@@ -12,26 +12,39 @@ jobs:
1212
NPM_REPOSITORY: "sonarsource-npm-public"
1313
SCOPE: ""
1414
PACKAGE: "eslint-plugin-sonarjs"
15-
steps:
16-
- name: Setup JFrog CLI
17-
uses: jfrog/setup-jfrog-cli@v2
18-
env:
19-
JF_ENV_1: ${{ secrets.REPOX_CLI_CONFIG_QA_DEPLOYER_LT }}
15+
steps:
16+
- name: Vault
17+
id: secrets
18+
uses: SonarSource/vault-action-wrapper@d1c1ab4ca5ad07fd9cdfe1eff038a39673dfca64 # tag=2.4.2-1
19+
with:
20+
url: ${{ inputs.vaultAddr }}
21+
secrets:
22+
development/artifactory/token/{REPO_OWNER_NAME_DASH}-qa-deployer access_token | qa_deployer_access_token;
23+
development/artifactory/token/{REPO_OWNER_NAME_DASH}-promoter access_token | promoter_access_token;
24+
development/kv/data/npmjs sonartech_npm_token | npm_token;
25+
- name: Setup JFrog for deploy
26+
uses: SonarSource/jfrog-setup-wrapper@eb712d76540e5d1f3756303f30387657fb204e52 # tag=2.4.1-1
27+
with:
28+
jfrogAccessToken: ${{ fromJSON(steps.secrets.outputs.vault).qa_deployer_access_token }}
2029
- uses: actions/checkout@v1
2130
- uses: actions/setup-node@v1
2231
with:
23-
node-version: 12
24-
- run: mv .github/workflows/.npmrc .npmrc
25-
- name: Publish npm package
32+
node-version: 12
33+
- run: mv .github/workflows/.npmrc .npmrc
34+
- name: Publish npm package
2635
env:
27-
NPM_TOKEN: ${{ secrets.SONARTECH_NPM_TOKEN }}
28-
REPOX_CLI_CONFIG_BUILD_PROMOTER_LT: ${{ secrets.REPOX_CLI_CONFIG_BUILD_PROMOTER_LT }}
36+
NPM_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).npm_token }}
2937
run: |
3038
jfrog rt npm-config --repo-resolve npm --repo-deploy sonarsource-npm-public-qa
31-
jfrog rt npm-ci
39+
jfrog rt npm-ci
3240
npm publish
3341
jfrog rt npm-publish --build-name=eslint-plugin-sonarjs --build-number=${{ github.event.release.tag_name }}
3442
jfrog rt build-publish eslint-plugin-sonarjs ${{ github.event.release.tag_name }}
35-
jfrog config import $REPOX_CLI_CONFIG_BUILD_PROMOTER_LT
43+
- name: Setup JFrog for promotion
44+
uses: SonarSource/jfrog-setup-wrapper@eb712d76540e5d1f3756303f30387657fb204e52 # tag=2.4.1-1
45+
with:
46+
jfrogAccessToken: ${{ fromJSON(steps.secrets.outputs.vault).promoter_access_token }}
47+
- name: Promote npm package
48+
run: |
3649
jfrog rt bpr --status it-passed eslint-plugin-sonarjs ${{ github.event.release.tag_name }} sonarsource-npm-public-builds
3750
jfrog rt bpr --status released eslint-plugin-sonarjs ${{ github.event.release.tag_name }} sonarsource-npm-public-releases

scripts/analyze_and_publish.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jfrog rt npm-publish --build-name=eslint-plugin-sonarjs --build-number=$BUILD_NU
2323
jfrog rt build-publish eslint-plugin-sonarjs $BUILD_NUMBER
2424
#QA tests could be run now to validate the artifacts and on success we promote.
2525
#configure jfrog cli to be able to promote build
26-
jfrog config import $REPOX_CLI_CONFIG_BUILD_PROMOTER
27-
#promote form QA to public builds
28-
jfrog rt bpr --status it-passed eslint-plugin-sonarjs $BUILD_NUMBER sonarsource-npm-public-builds
26+
jfrog config edit repox --url $ARTIFACTORY_URL --access-token $ARTIFACTORY_PROMOTE_ACCESS_TOKEN
27+
#promote from QA to public builds
28+
jfrog rt bpr --status it-passed eslint-plugin-sonarjs $BUILD_NUMBER sonarsource-npm-public-builds

0 commit comments

Comments
 (0)