-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5406271
Added descriptions for composite actions.
shethj 30a241d
Add NPM token expiry verification script
shethj 5664a40
Add emoji to slack notification
shethj 3c81e58
Merge branch 'develop' into feature/update-publish-to-npm-auth
shethj c63d78f
Merge branch 'develop' into feature/update-publish-to-npm-auth
shethj 1936bff
Add a link to PWA Kit release doc
shethj 2ae46a9
Remove redundant env set
shethj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: bundlesize | ||
| description: Check bundle size against maximum file size limits | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: check_clean | ||
| description: Check if repository has uncommitted changes | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: create_mrt | ||
| description: Create MRT credentials file | ||
| inputs: | ||
| mobify_user: | ||
| description: "Mobify user email" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: datadog | ||
| description: Send metrics to Datadog | ||
| inputs: | ||
| datadog_api_key: | ||
| description: "Datadog API key" | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: lighthouse_ci | ||
| description: Run Lighthouse CI performance tests | ||
| runs: | ||
| using: composite | ||
| steps: | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: linting | ||
| description: Run linting checks on the codebase | ||
| inputs: | ||
| cwd: | ||
| required: false | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: push_to_mrt | ||
| description: Push bundle to MRT (Managed Runtime) | ||
| inputs: | ||
| CWD: | ||
| description: Project directory | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: smoke_tests | ||
| description: Run smoke tests on npm scripts | ||
| inputs: | ||
| dir: | ||
| required: false | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| name: snyk | ||
| description: Run Snyk security audit on the project | ||
| inputs: | ||
| snyk_token: | ||
| description: "Snyk token" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ jobs: | |
| echo "monorepo_version_base=$version" >> "$GITHUB_ENV" | ||
| version_major=`echo "$version" | cut -d "." -f 1` | ||
| echo "monorepo_version_major=$version_major" >> "$GITHUB_ENV" | ||
| echo "nightly_version=${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }}" ?? "$GITHUB_ENV" | ||
|
|
||
| - name: Get nightly version | ||
| run: echo "nightly_version=${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }}" >> "$GITHUB_ENV" | ||
|
|
@@ -116,7 +115,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 +127,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 the instructions in this doc: ${{ secrets.PWA_KIT_RELEASE_DOC_LINK }}" | ||
| } | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.