File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -136,3 +136,35 @@ jobs:
136
136
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
137
137
# https://github.com/sourcegraph/codenotify/issues/19
138
138
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
+ );
You can’t perform that action at this time.
0 commit comments