Skip to content

Commit be67449

Browse files
committed
Merge remote-tracking branch 'upstream/main' into support-more-deployments-logic
2 parents d8b71ed + 648679e commit be67449

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dist/* linguist-generated
1+
dist/* linguist-generated -diff

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ jobs:
255255

256256
This is the same as `deactivate-env`, except deletes the environment entirely. See [`step: deactivate-env`](#step-deactivate-env) for more details.
257257

258-
Note that the default `GITHUB_TOKEN` does not allow environment deletion - you have to set a personal access token and provide it in the `token` input.
258+
Note that the default `GITHUB_TOKEN` does not allow environment deletion - you have to set a personal access token with `deployments:write` and `administration:write` permissions and provide it in the `token` input.
259259

260260
Refer to the [core configuration](#configuration) for available [`inputs`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepswith).
261261

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ branding:
55
icon: bookmark
66
color: yellow
77
runs:
8-
using: node16
8+
using: node20
99
main: dist/index.js
1010

1111
inputs:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/delete.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ async function deleteEnvironment(
3636
log.info(`${environment}: ${existing} deployments deleted`);
3737
}
3838

39-
await github.rest.repos.deleteAnEnvironment({
40-
owner: context.owner,
41-
repo: context.repo,
42-
environment_name: environment,
43-
});
44-
log.info(`${environment}: environment deleted`);
39+
log.info(`deleting environment: "${environment}"`);
40+
try {
41+
await github.rest.repos.deleteAnEnvironment({
42+
owner: context.owner,
43+
repo: context.repo,
44+
environment_name: environment,
45+
});
46+
log.info(`${environment}: environment deleted`);
47+
} catch (error: any) {
48+
if ("status" in error && error.status == 404) {
49+
log.fail(
50+
`got a 404 deleting ${environment}, check that your PAT has repo scope and that the pat user is an admin`
51+
);
52+
} else {
53+
log.fail(`error while deleting ${environment}: ${error}`);
54+
log.debug(error);
55+
}
56+
}
4557
}
4658

4759
export default deleteEnvironment;

0 commit comments

Comments
 (0)