-
Notifications
You must be signed in to change notification settings - Fork 212
Add NPM Token expiry alert to nightly workflow #3582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5406271
30a241d
5664a40
3c81e58
c63d78f
1936bff
2ae46a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: bundlesize | ||
| description: Check bundle size against maximum file size limits | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: check_clean | ||
| description: Check if repository has uncommitted changes | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: create_mrt | ||
| description: Create MRT credentials file | ||
| inputs: | ||
| mobify_user: | ||
| description: "Mobify user email" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: datadog | ||
| description: Send metrics to Datadog | ||
| inputs: | ||
| datadog_api_key: | ||
| description: "Datadog API key" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: lighthouse_ci | ||
| description: Run Lighthouse CI performance tests | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: linting | ||
| description: Run linting checks on the codebase | ||
| inputs: | ||
| cwd: | ||
| required: false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: push_to_mrt | ||
| description: Push bundle to MRT (Managed Runtime) | ||
| inputs: | ||
| CWD: | ||
| description: Project directory | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: smoke_tests | ||
| description: Run smoke tests on npm scripts | ||
| inputs: | ||
| dir: | ||
| required: false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: snyk | ||
| description: Run Snyk security audit on the project | ||
| inputs: | ||
| snyk_token: | ||
| description: "Snyk token" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,7 @@ jobs: | |
| with: | ||
| payload: | | ||
| { | ||
| "message": "Successfully released PWA Kit v${{ env.nightly_version }}" | ||
| "message": "✅ Successfully released PWA Kit v${{ env.nightly_version }}" | ||
| } | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
|
|
@@ -128,7 +128,37 @@ jobs: | |
| with: | ||
| payload: | | ||
| { | ||
| "message": "Failed to release PWA Kit v${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }} (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | ||
| "message": "❌Failed to release PWA Kit v${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }} (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | ||
| } | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
|
|
||
| - name: Check NPM Token Expiry | ||
| if: always() | ||
| run: | | ||
| LAST_ROTATION="${{ secrets.NPM_TOKEN_LAST_ROTATION_DATE }}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the instructions for updating this secret are in the doc? This NPM token corresponds to the one we use for releases, correct?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct. |
||
|
|
||
| if [ -z "$LAST_ROTATION" ]; then | ||
| echo "NPM_TOKEN_LAST_ROTATION_DATE secret not set, skipping expiry check" | ||
| exit 0 | ||
| fi | ||
|
|
||
| CURRENT_DATE=$(date +%s) | ||
| EXPIRY_DATE=$(( $LAST_ROTATION + 7776000 )) # 90 days in seconds (90 * 24 * 60 * 60) | ||
| DAYS_LEFT=$(( ($EXPIRY_DATE - $CURRENT_DATE) / 86400 )) | ||
|
|
||
| echo "NPM Token last rotated: $(date -d @$LAST_ROTATION +'%Y-%m-%d')" | ||
| echo "Days until expiry: $DAYS_LEFT" | ||
| echo "days_left=$DAYS_LEFT" >> "$GITHUB_ENV" | ||
| echo "should_notify=$( [ $DAYS_LEFT -le 10 ] && echo 'true' || echo 'false' )" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Send Token Expiry Warning to Slack | ||
| if: always() && env.should_notify == 'true' | ||
| uses: slackapi/slack-github-action@v1.23.0 | ||
| with: | ||
| payload: | | ||
| { | ||
| "message": "⚠️ NPM Token expiring soon! Only ${{ env.days_left }} days remaining. Please rotate the token using instructions in PWA Kit Release Doc." | ||
|
||
| } | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github actions now requires description as mandatory field for all composite actions.