-
Notifications
You must be signed in to change notification settings - Fork 199
Reduce CI deployment noise #3303
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
|
||
| name: 'cleanup-deployments' | ||
| description: 'Removes deployment entries from the PR timeline created by environment-gated jobs. Marks each deployment as inactive then deletes it. Does not affect CI check results.' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - uses: actions/github-script@v8 | ||
| if: github.event_name == 'pull_request_target' | ||
| with: | ||
| script: | | ||
| const sha = context.payload.pull_request?.head?.sha || context.sha; | ||
| for (const env of ['auto-approve']) { | ||
| const deployments = await github.rest.repos.listDeployments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| environment: env, | ||
| sha: sha, | ||
| per_page: 100, | ||
| }); | ||
| console.log(`Found ${deployments.data.length} deployments for ${env} (sha: ${sha})`); | ||
| for (const d of deployments.data) { | ||
| try { | ||
| await github.rest.repos.createDeploymentStatus({ | ||
|
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. what do we even use this notion of "deployments" for? instead of cleaning up the unneeded deployments, can we just disable them altogether? |
||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| deployment_id: d.id, | ||
| state: 'inactive', | ||
| }); | ||
| await github.rest.repos.deleteDeployment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| deployment_id: d.id, | ||
| }); | ||
| } catch (e) { | ||
| console.log(`Failed to delete deployment ${d.id}: ${e.message}`); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ env: | |
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| deployments: write | ||
|
|
||
| jobs: | ||
| authorization-check: | ||
|
|
@@ -123,3 +124,14 @@ jobs: | |
| - name: Push Images | ||
| run: | | ||
| docker push ${{ steps.images.outputs.latest }} | ||
|
|
||
|
|
||
| cleanup-deployments: | ||
| if: always() | ||
| needs: [build, push] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| deployments: write | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
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. why v5 here but v4 below? |
||
| - uses: ./.github/actions/cleanup-deployments | ||
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.
presumably 100 is enough today, but do we have to limit page size? if the page size grows >100, do we need to paginate here?