-
Notifications
You must be signed in to change notification settings - Fork 14
Deploy centralized organization stale bot #48
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
13 commits
Select commit
Hold shift + click to select a range
20736b8
Deploy centralized organization stale bot
ChrisGe4 83cb8b8
Add required organization security workflows
ChrisGe4 d029913
Improve the workflow
ChrisGe4 1e373e0
Upgrade tool versions
ChrisGe4 4889929
Upgrade action-actionlint versions
ChrisGe4 e677127
pin tool versions
ChrisGe4 cdacfd4
fix token permissions lint error
ChrisGe4 5229127
ensure all yaml string values are quoted
ChrisGe4 4e21ea3
fix error
ChrisGe4 7e3290e
fix linter warning
ChrisGe4 f7eb013
remove ref from scorecard.yml
ChrisGe4 bf0adaa
Update .github/workflows/centralized-stale.yml
ChrisGe4 ac68222
fix linter error
ChrisGe4 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
|
ChrisGe4 marked this conversation as resolved.
|
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: 'Actionlint' | ||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: 'read' | ||
| pull-requests: 'write' | ||
|
|
||
| concurrency: | ||
| group: 'actionlint-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: 'ubuntu-latest' | ||
| steps: | ||
| - uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # ratchet:actions/checkout@v6 | ||
| - name: 'Run actionlint with reviewdog' | ||
| uses: 'reviewdog/action-actionlint@6fb7acc99f4a1008869fa8a0f09cfca740837d9d' # ratchet:reviewdog/action-actionlint@v1.72.0 | ||
| with: | ||
| fail_level: 'error' | ||
| reporter: 'github-pr-check' |
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 |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: 'Centralized Organization Stale Bot' | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| permissions: {} | ||
| on: | ||
| schedule: | ||
| # Run daily at 01:00 UTC | ||
| - cron: '0 1 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| # Stage 1: Query the organization for all active repositories | ||
| fetch-repositories: | ||
| runs-on: 'ubuntu-latest' | ||
| outputs: | ||
| matrix: '${{ steps.set-matrix.outputs.repos }}' | ||
| steps: | ||
| - id: 'auth-minty' | ||
| name: 'Authenticate to Google Cloud' | ||
| uses: 'google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f' # ratchet:google-github-actions/auth@v2 | ||
| with: | ||
| create_credentials_file: false | ||
| export_environment_variables: false | ||
| workload_identity_provider: '${{ vars.TOKEN_MINTER_WIF_PROVIDER }}' | ||
| service_account: '${{ vars.TOKEN_MINTER_WIF_SERVICE_ACCOUNT }}' | ||
| token_format: 'id_token' | ||
| id_token_audience: '${{ vars.TOKEN_MINTER_SERVICE_AUDIENCE }}' | ||
| id_token_include_email: true | ||
|
|
||
| - id: 'mint-github-token' | ||
| uses: 'abcxyz/github-token-minter/.github/actions/minty@45c29ca3418ff3bb3ad5815d88a80536efeba21b' # ratchet:abcxyz/github-token-minter/.github/actions/minty@main | ||
| with: | ||
| id_token: '${{ steps.auth-minty.outputs.id_token }}' | ||
| service_url: '${{ vars.TOKEN_MINTER_SERVICE_URL }}' | ||
| requested_permissions: |- | ||
| { | ||
| "scope": "stale-bot", | ||
| "repositories": ["*"], | ||
| "org_name": "google-github-actions" | ||
| } | ||
|
|
||
| - name: 'List active repositories' | ||
| id: set-matrix | ||
| env: | ||
| GH_TOKEN: '${{ steps.mint-github-token.outputs.token }}' | ||
| run: | | ||
| # Query GitHub API for active, public, non-forked repositories and force single-line JSON to prevent GITHUB_OUTPUT truncation | ||
| REPOS=$(gh api --paginate /orgs/google-github-actions/repos | jq -s 'add | [.[] | select(.archived == false and .private == false and .fork == false) | .name]' -c) | ||
| echo "repos=${REPOS}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # Stage 2: Fan out official actions/stale across all discovered repositories | ||
| apply-stale-rules: | ||
| needs: fetch-repositories | ||
| runs-on: 'ubuntu-latest' | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| repo: '${{ fromJson(needs.fetch-repositories.outputs.matrix) }}' | ||
|
|
||
| steps: | ||
| - id: 'auth-minty' | ||
| name: 'Authenticate to Google Cloud' | ||
| uses: 'google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f' # ratchet:google-github-actions/auth@v2 | ||
| with: | ||
| create_credentials_file: false | ||
| export_environment_variables: false | ||
| workload_identity_provider: '${{ vars.TOKEN_MINTER_WIF_PROVIDER }}' | ||
| service_account: '${{ vars.TOKEN_MINTER_WIF_SERVICE_ACCOUNT }}' | ||
| token_format: 'id_token' | ||
| id_token_audience: '${{ vars.TOKEN_MINTER_SERVICE_AUDIENCE }}' | ||
| id_token_include_email: true | ||
|
|
||
| - id: 'mint-github-token' | ||
| uses: 'abcxyz/github-token-minter/.github/actions/minty@45c29ca3418ff3bb3ad5815d88a80536efeba21b' # ratchet:abcxyz/github-token-minter/.github/actions/minty@main | ||
| with: | ||
| id_token: '${{ steps.auth-minty.outputs.id_token }}' | ||
| service_url: '${{ vars.TOKEN_MINTER_SERVICE_URL }}' | ||
| requested_permissions: |- | ||
| { | ||
| "scope": "stale-bot", | ||
| "repositories": ["${{ matrix.repo }}"], | ||
| "org_name": "google-github-actions" | ||
| } | ||
|
|
||
| - name: 'Run official stale bot' | ||
| uses: 'actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f' # ratchet:actions/stale@v10.2.0 | ||
| env: | ||
| GITHUB_REPOSITORY: 'google-github-actions/${{ matrix.repo }}' | ||
| with: | ||
| repo-token: '${{ steps.mint-github-token.outputs.token }}' | ||
| operations-per-run: 300 # Increased burndown limit for first execution | ||
|
|
||
| # Issue configuration (60 days total: 53 inactive + 7 warning) | ||
| days-before-issue-stale: 53 | ||
| days-before-issue-close: 7 | ||
| stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.' | ||
| stale-issue-label: 'stale' | ||
|
|
||
| # PR configuration (30 days total: 23 inactive + 7 warning) | ||
| days-before-pr-stale: 23 | ||
| days-before-pr-close: 7 | ||
| stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. Please leave a comment to remove this status.' | ||
| stale-pr-label: 'stale' | ||
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: 'Scorecard' | ||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: 'read-all' | ||
|
|
||
| jobs: | ||
| analyze: | ||
| runs-on: 'ubuntu-latest' | ||
| permissions: | ||
| contents: 'read' | ||
| security-events: 'write' | ||
| id-token: 'write' | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # ratchet:actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
| - name: 'Run Scorecard' | ||
| uses: 'ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a' # ratchet:ossf/scorecard-action@v2.4.3 | ||
| with: | ||
| results_file: 'results.sarif' | ||
| results_format: 'sarif' | ||
| publish_results: false | ||
| - name: 'Upload to GitHub Security Tab' | ||
| uses: 'github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13' # ratchet:github/codeql-action/upload-sarif@v4.35.1 | ||
| with: | ||
| sarif_file: 'results.sarif' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Uh oh!
There was an error while loading. Please reload this page.