-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schedule npm audit to run on the commit that is deployed to prod
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: npm-audit-alert-prod | ||
|
||
on: | ||
schedule: | ||
- cron: "0 12 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
npm-audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get commit hash of the version installed to production | ||
run: | | ||
echo "COMMIT_HASH=$( curl "https://dashboard.ops.opintopolku.fi/data/services" | jq --raw-output '.services[] | select(.name == "rekisterointi") | .environments.sade.commit_hash' )" | ||
id: get_prod_version | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.get_prod_version.outputs.COMMIT_HASH }} | ||
- name: Install deps | ||
run: npm ci | ||
working-directory: rekisterointi-ui | ||
- name: Run npm audit | ||
run: | | ||
npm audit 2>&1 | tee audit.log | ||
result_code=${PIPESTATUS[0]} | ||
content="$(cat audit.log)" | ||
content="${content//'%'/'%25'}" | ||
content="${content//$'\n'/'%0A'}" | ||
content="${content//$'\r'/'%0D'}" | ||
echo "content=$content" >> "$GITHUB_OUTPUT" | ||
exit $result_code | ||
id: run_audit | ||
working-directory: rekisterointi-ui | ||
- name: Send Slack alert if previous steps failed | ||
if: failure() | ||
run: | | ||
curl -X POST -H 'Content-type: application/json' --data '{"channel": "#yleiskäyttöiset-alerts", "icon_emoji": ":warning:", "text": "*${{ github.repository }}:*\n${{ steps.run_audit.outputs.content }}"}' ${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters