Skip to content

Commit 65b9423

Browse files
authored
Update tox.yml
1 parent ba170fa commit 65b9423

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/tox.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,35 @@ jobs:
136136
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137137
# https://github.com/sourcegraph/codenotify/issues/19
138138
continue-on-error: true
139+
delete_github_deployments:
140+
runs-on: ubuntu-latest
141+
needs: check
142+
if: ${{ always() }}
143+
steps:
144+
- name: Delete Previous deployments
145+
uses: actions/github-script@v6
146+
env:
147+
GITHUB_SHA_HEAD: ${{ github.event.pull_request.head.sha }}
148+
with:
149+
script: |
150+
const { GITHUB_SHA_HEAD } = process.env
151+
const deployments = await github.rest.repos.listDeployments({
152+
owner: context.repo.owner,
153+
repo: context.repo.repo,
154+
sha: GITHUB_SHA_HEAD
155+
});
156+
await Promise.all(
157+
deployments.data.map(async (deployment) => {
158+
await github.rest.repos.createDeploymentStatus({
159+
owner: context.repo.owner,
160+
repo: context.repo.repo,
161+
deployment_id: deployment.id,
162+
state: 'inactive'
163+
});
164+
return github.rest.repos.deleteDeployment({
165+
owner: context.repo.owner,
166+
repo: context.repo.repo,
167+
deployment_id: deployment.id
168+
});
169+
})
170+
);

0 commit comments

Comments
 (0)