-
Notifications
You must be signed in to change notification settings - Fork 55
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
docs: instructions on verifying token access to a repository #387
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4461a5
docs: instructions on verifying token access to a repository
andimiya f4ae9f1
docs: prettier updates
andimiya c32ea51
docs: language update
andimiya 57de64a
docs: correct more linting CI errors
andimiya 2070ad2
docs: more lint fixes
andimiya 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 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 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,65 @@ | ||
## Verify Token Access to Repository | ||
|
||
Github PAT token access can be confusing. Here's a quick way to test if the token you're using is authorized to access your repository. | ||
|
||
**Remove this snippet after you've verified your token.** | ||
|
||
- Make sure you follow the token setup instructions [here](https://github.com/github/issue-metrics/tree/main?tab=readme-ov-file#use-as-a-github-action) first. | ||
|
||
- Replace `{owner/repo}` with your own repo information. | ||
|
||
- Add this snippet to your workflow.yml. | ||
|
||
``` | ||
- name: Check GitHub token permissions | ||
run: | | ||
curl -H "Authorization: token ${{ secrets.GH_TOKEN }}" https://api.github.com/repos/{owner/repo} | ||
``` | ||
|
||
- Go to your repository Actions in Github and run your job. | ||
- In the job run details, click into the results of `Check Github token permissions` | ||
- You should see your token details with no errors. | ||
|
||
Example of the snippet in the full workflow: | ||
|
||
``` | ||
name: Monthly issue metrics | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '3 2 1 * *' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: issue metrics | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: read | ||
|
||
steps: | ||
- name: Check GitHub token permissions | ||
run: | | ||
curl -H "Authorization: token ${{ secrets.GH_TOKEN }}" https://api.github.com/{owner/repo} | ||
- name: Get dates for last month | ||
shell: bash | ||
run: | | ||
# Calculate the first day of the previous month | ||
first_day=$(date -d "last month" +%Y-%m-01) | ||
|
||
# Calculate the last day of the previous month | ||
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) | ||
|
||
#Set an environment variable with the date range | ||
echo "$first_day..$last_day" | ||
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" | ||
|
||
- name: Run issue-metrics tool | ||
uses: github/issue-metrics@v3 | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
SEARCH_QUERY: 'repo:{owner/repo} is:issue created:${{ env.last_month }}' | ||
``` |
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.
This is the output in Github actions.
I don't think this opens people up to security issues even if they publish this along with their action, but want a second opinion here @jmeridth @zkoppert
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.
No security concerns. GitHub Actions masks the token in the output. This is a great addition.