Skip to content
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

AAE-22415 Deployment message cleanup #627

Merged
merged 31 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a618c04
AAE-22415 add action to delete deployments
revatilimaye May 27, 2024
2d928b9
modify action
revatilimaye May 27, 2024
6b60e61
fix syntax error
revatilimaye May 27, 2024
03abf4b
fix syntax error
revatilimaye May 27, 2024
d67a0da
fix syntax error
revatilimaye May 27, 2024
2451baf
modify script
revatilimaye May 28, 2024
4eade66
Resolve review comments
revatilimaye May 28, 2024
3c7a1df
revert changes in dependabot.yml
revatilimaye May 28, 2024
4f4300c
resolve review comments
revatilimaye May 28, 2024
2d043de
modify readme.md
revatilimaye May 28, 2024
f9a87e3
resolve review comments
revatilimaye May 28, 2024
6567e4e
move script to js
revatilimaye May 29, 2024
60c5fd2
fix syntax error
revatilimaye May 29, 2024
0cb67db
fix syntax error
revatilimaye May 29, 2024
1f7867c
remove branch checkout
revatilimaye May 29, 2024
f0449e1
resolve review comments
revatilimaye May 29, 2024
5437ba2
remove extra empty line
atchertchian May 29, 2024
eddb72e
reindex script
atchertchian May 29, 2024
da2488d
handle optional parameter
revatilimaye May 30, 2024
d8d56c6
modify script path
revatilimaye May 30, 2024
e5e50bf
handle optional parameter
revatilimaye May 30, 2024
49c4f84
modify parameters
revatilimaye May 30, 2024
e910534
add logs
revatilimaye May 30, 2024
4b43723
modify path
revatilimaye May 30, 2024
19494c4
modify path
revatilimaye May 30, 2024
56e61e5
modify path
revatilimaye May 30, 2024
8991288
modify params
revatilimaye May 30, 2024
203d542
remove ;
revatilimaye May 30, 2024
6779b65
fix params
revatilimaye May 30, 2024
81db153
remove logs, change version
revatilimaye May 30, 2024
b16f98d
format
revatilimaye May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/actions/github-deployments-delete/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Delete Github Deployments

description:
Deletes all GitHub deployments on a given branch.
Used as workaround to delete the flood of messages visible on some PRs where environments are leveraged but deployments are not.

inputs:
branch-name:
description: The name of the branch for the deployments
required: true
environment:
description: The optional environment for the deployments
required: false

runs:
using: composite
steps:
- name: delete-deployments
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
with:
script: |
atchertchian marked this conversation as resolved.
Show resolved Hide resolved
const options={
ref:'${{ inputs.branch-name }}',
environment:'${{ inputs.environment }}'
};
const githubActionPath = process.env.GITHUB_ACTION_PATH;
const script = require(`${githubActionPath}/deleteDeploymentScript.js`);
await script({github, context, options});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = async ({github, context, options}) => {
const perPage = 100;
let page = 1;
let allDeployments = [];
const {ref,environment} = options;

while(true) {
const deployments = await github.rest.repos.listDeployments({
owner: context.repo.owner,
repo: context.repo.repo,
ref: ref,
per_page: perPage,
page: page,
environment: environment
});

allDeployments = [...allDeployments, ...deployments.data];
if (!deployments.data.length) {
break;
}
page++;
}

await Promise.all(
allDeployments.map(async (deployment) => {
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.id,
state: 'inactive'
});
return github.rest.repos.deleteDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.id
});
})
);
}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ updates:
catch-all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/.github/actions/github-deployments-delete"
schedule:
interval: "weekly"
groups:
catch-all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/.github/actions/github-download-file"
schedule:
Expand Down
18 changes: 18 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Here follows the list of GitHub Actions topics available in the current document
- [git-latest-tag](#git-latest-tag)
- [github-check-upcoming-runs](#github-check-upcoming-runs)
- [github-deployment-create and github-deployment-status-update](#github-deployment-create-and-github-deployment-status-update)
- [github-deployments-delete](#github-deployments-delete)
- [github-download-file](#github-download-file)
- [helm-build-chart](#helm-build-chart)
- [helm-integration-tests](#helm-integration-tests)
Expand Down Expand Up @@ -683,6 +684,23 @@ jobs:
state: success
```

### github-deployments-delete

Deletes all GitHub deployments on a given branch.
Used as workaround to delete the flood of messages visible on some PRs where environments are leveraged but deployments are not.

Sample usage:

```yaml
permissions:
deployments: write # This is required for deployment statuses management

steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/github-deployments-delete@ref
with:
branch-name: ${{ github.head_ref }}
```

### github-download-file

Download a file from another repository.
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.27.1
v5.28.0
Loading