Skip to content

Commit b180199

Browse files
authored
Add daily credentials verification workflow (#3314)
## Motivation and Context Adds a daily credentials verification workflow ## Description We rotate credentials manually. Those credentials are `RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN` and `RELEASE_AUTOMATION_BOT_PAT`. While the validity of those credentials are checked during dry-runs of [the release workflow](https://github.com/smithy-lang/smithy-rs/blob/main/.github/workflows/release.yml) we've had instances where a dry-run failed because it was not idempotent and we nevertheless kicked off a production run, only to find out the token was invalid. This raises the need for daily credentials verification, and the PR adds one. The workflow will check the validly of two credentials `RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN` and `RELEASE_AUTOMATION_BOT_PAT`, each checked by a separate job. Upon failure, a job will notify us as follows: <img width="1056" alt="Screenshot 2023-12-12 at 6 26 40 PM" src="https://github.com/smithy-lang/smithy-rs/assets/15333866/1105b26b-7064-4ba2-849a-5969d59f1dd4"> ## Testing Manually triggered failures and got the messages in the above screenshot. Also verified a successful run with valid credentials. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 7dfd609 commit b180199

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Daily credentials verification
2+
on:
3+
schedule:
4+
# Runs 00:00 UTC every day
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
# Verifies the token used by the bot to publish crates to crates.io
10+
verify-crates-io-token:
11+
name: Verify Crates.io Token
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout smithy-rs
15+
uses: actions/checkout@v3
16+
- name: Verify Crates.io Token
17+
shell: bash
18+
env:
19+
RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN: ${{ secrets.RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN }}
20+
run: |
21+
cargo login -- "${RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN}"
22+
echo "Checking cargo auth token..."
23+
# "cargo login" only saves a token and does not actually use it, so we use "cargo yank" to verify the token.
24+
# This version has already been yanked, so it is safe to execute the command below repeatedly.
25+
# This command succeeds if we have a token with permission to yank the crate.
26+
cargo yank aws-sigv4 --version 0.55.0
27+
- name: Notify Slack on Failure
28+
if: failure()
29+
env:
30+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
31+
run: |
32+
curl -X POST "${SLACK_WEBHOOK_URL}" -H 'Content-type: application/json' \
33+
--data '{"workflow_msg":"⚠️ Invalid crates.io token. Create a new token as soon as possible!"}'
34+
35+
# Verifies the token used to perform actions on the repository on behalf of the bot user
36+
verify-personal-access-token:
37+
name: Verify Personal Access Token
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout smithy-rs
41+
# To test the validity of the personal access token, we only need to perform checkout with the specified token.
42+
uses: actions/checkout@v3
43+
with:
44+
token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
45+
- name: Notify Slack on Failure
46+
if: failure()
47+
env:
48+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
49+
run: |
50+
curl -X POST "${SLACK_WEBHOOK_URL}" -H 'Content-type: application/json' \
51+
--data '{"workflow_msg":"⚠️ Invalid GitHub personal access token. Create a new token as soon as possible!"}'

0 commit comments

Comments
 (0)