1-
21name : Build NPM Package
2+
33on :
44 push :
55 branches : [ main ]
88
99permissions :
1010 checks : write
11- contents : read
11+ contents : write
1212 packages : read
13+
1314env :
14- API_URL : https://app.audit.dev. invisirisk.com
15+ API_URL : https://app.invisirisk.com
1516
1617jobs :
1718 create_scan_in_IR_Portal :
2930 - name : Parse Response
3031 id : parseResponse
3132 run : echo "scan_id=${{fromJSON(steps.createScan.outputs.response).data.scan_id}}" >> "$GITHUB_OUTPUT"
33+
3234 ecr_details :
3335 runs-on : ubuntu-latest
3436 outputs :
4143 id : fetchECRDetails
4244 uses : fjogeleit/http-request-action@v1.15.1
4345 with :
44- url : ' ${{env.API_URL}}/utilityapi/v1/registry?api_key=${{secrets.VB_API_KEY}}'
45- method : ' GET'
46+ url : ' ${{env.API_URL}}/utilityapi/v1/registry?api_key=${{secrets.VB_API_KEY}}'
47+ method : ' GET'
4648 - name : Decoding VB Token
4749 id : parseToken
4850 run : echo "DECODED_TOKEN=$(echo ${{ fromJson(steps.fetchECRDetails.outputs.response).data }} | base64 -d)" >> "$GITHUB_OUTPUT"
@@ -53,44 +55,73 @@ jobs:
5355 echo "token=${{fromJSON(steps.parseToken.outputs.DECODED_TOKEN).password}}" >> "$GITHUB_OUTPUT"
5456 echo "region=${{fromJSON(steps.parseToken.outputs.DECODED_TOKEN).region}}" >> "$GITHUB_OUTPUT"
5557 echo "registry_id=${{fromJSON(steps.parseToken.outputs.DECODED_TOKEN).registry_id}}" >> "$GITHUB_OUTPUT"
56-
58+
5759 start_proxy_and_build :
5860 runs-on : ubuntu-latest
5961 needs : [create_scan_in_IR_Portal, ecr_details]
6062 services :
6163 pse :
62- image : 282904853176.dkr.ecr.us-west-2.amazonaws.com/invisirisk/pse-proxy:dev-test
64+ image : 282904853176.dkr.ecr.us-west-2.amazonaws.com/invisirisk/pse-proxy:latest
6365 credentials :
6466 username : ${{needs.ecr_details.outputs.ecr_username}}
6567 password : ${{needs.ecr_details.outputs.ecr_token}}
66- env :
67- PSE_DEBUG_FLAG : --alsologtostderr
68- POLICY_LOG : t
69- INVISIRISK_JWT_TOKEN : ${{secrets.VB_API_KEY}}
70- INVISIRISK_PORTAL : https://app.audit.dev .invisirisk.com/
71- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68+ env :
69+ PSE_DEBUG_FLAG : --alsologtostderr
70+ POLICY_LOG : t
71+ INVISIRISK_JWT_TOKEN : ${{secrets.VB_API_KEY}}
72+ INVISIRISK_PORTAL : https://app.invisirisk.com/
73+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7274 container :
7375 image : node:18-alpine
7476 options : --cap-add=NET_ADMIN
7577 strategy :
7678 matrix :
7779 node-version : [18.x]
7880 steps :
79- - env :
80- SCAN_ID : ${{ needs.create_scan_in_IR_Portal.outputs.scan_id }}
81- run : echo $SCAN_ID
82- - uses : invisirisk/pse-action@v1.0.8
83- with :
81+ - name : Print Scan ID
82+ env :
83+ SCAN_ID : ${{ needs.create_scan_in_IR_Portal.outputs.scan_id }}
84+ run : echo $SCAN_ID
85+
86+ - name : PSE Action
87+ uses : invisirisk/pse-action@v1.0.8
88+ with :
8489 github-token : ${{ secrets.GITHUB_TOKEN }}
8590 SCAN_ID : ${{ needs.create_scan_in_IR_Portal.outputs.scan_id }}
86- - name : Checkout the code
87- uses : actions/checkout@v3
88- - name : Use Node.js ${{ matrix.node-version }}
89- uses : actions/setup-node@v3
90- with :
91- node-version : ${{ matrix.node-version }}
92- - run : npm install
93- - run : npm ci
94- - run : npm run build --if-present
95- - run : npm test
96-
91+
92+ - name : Checkout code
93+ uses : actions/checkout@v3
94+ with :
95+ fetch-depth : 0
96+ token : ${{ secrets.GITHUB_TOKEN }}
97+
98+ - name : Configure Git
99+ run : |
100+ git config --global --add safe.directory "${GITHUB_WORKSPACE}"
101+ git config --global user.name "GitHub Actions"
102+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
103+
104+ - name : Setup Node.js
105+ uses : actions/setup-node@v3
106+ with :
107+ node-version : ${{ matrix.node-version }}
108+
109+ - name : Install dependencies
110+ run : |
111+ npm install
112+ npm ci
113+
114+ - name : Build and test
115+ run : |
116+ npm run build --if-present
117+ npm test
118+
119+ - name : Commit and push changes
120+ run : |
121+ if [[ -n "$(git status --porcelain)" ]]; then
122+ git add .
123+ git commit -m "chore: automated build and test updates [skip ci]"
124+ git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }}
125+ else
126+ echo "No changes to commit"
127+ fi
0 commit comments