-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from DonColon/dev
Finished cleanup workflow
- Loading branch information
Showing
4 changed files
with
69 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default async ({ core, context, github }) => { | ||
const { owner, repo } = context.repo; | ||
|
||
const parameters = { | ||
owner, | ||
repo, | ||
per_page: 100, | ||
environment: "netlify" | ||
} | ||
|
||
for await(const response of github.paginate.iterator(github.rest.repos.listDeployments, parameters)) { | ||
const { data: deployments } = response; | ||
|
||
core.info(`${deployments.length} deployments found`); | ||
|
||
for(const deployment of deployments) { | ||
try { | ||
await github.rest.repos.deleteDeployment({ | ||
owner, | ||
repo, | ||
deployment_id: deployment.id, | ||
}); | ||
} catch(error) { | ||
core.info(`Deployment ${deployment.id}: ${error.message}`); | ||
} | ||
} | ||
} | ||
|
||
core.info(`Deleted all deployments`); | ||
}; |
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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
export default async ({ core, context, github }) => { | ||
const { owner, repo } = context.repo; | ||
|
||
const { data: workflowRuns } = await github.rest.actions.listWorkflowRunsForRepo({ | ||
const parameters = { | ||
owner, | ||
repo | ||
}); | ||
repo, | ||
per_page: 100, | ||
status: "completed" | ||
} | ||
|
||
for await(const response of github.paginate.iterator(github.rest.actions.listWorkflowRunsForRepo, parameters)) { | ||
const { data: workflowRuns } = response; | ||
|
||
for(const workflowRun of workflowRuns) { | ||
await github.rest.actions.deleteWorkflowRun({ | ||
owner, | ||
repo, | ||
run_id: workflowRun.id, | ||
}); | ||
core.info(`${workflowRuns.length} workflow runs found`); | ||
|
||
for(const workflowRun of workflowRuns) { | ||
await github.rest.actions.deleteWorkflowRun({ | ||
owner, | ||
repo, | ||
run_id: workflowRun.id, | ||
}); | ||
} | ||
} | ||
|
||
core.info(`Deleted all workflow runs`); | ||
}; |
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