Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to remove the "environment" tab from a Github repo
#!/usr/bin/env bash
# Remove Project Environment artefacts from a Github project: This script
# can be used to remove all "environment" artefacts from a project that,
# for example, no longer uses github-pages. Doing so would also remove the
# "environment" tab from the Github repository.
# The script requires for `curl` and `jq` to be in your PATH. You will also
# need to define a personal access token with `repo_deployment` scope on
# Github, and update the values of API_URL_BASE and ACCESS_TOKEN bellow.
# Personal access token can be defined at:
# Settings > Developer settings > Personal access tokens
# ie --
for id in $(curl -sL ${API_URL_BASE}/deployments | jq '.[].id'); do
echo "ID: ${id}"
echo -n " - update state: "
curl -sL \
-H "accept: application/vnd.github.ant-man-preview+json" \
-H "authorization: token ${ACCESS_TOKEN}" \
-X POST -d '{"state":"inactive"}' \
${API_URL_BASE}/deployments/${id}/statuses \
| jq '.state'
echo -n " - delete artefact: "
curl -sL \
-H "authorization: token ${ACCESS_TOKEN}" \
${API_URL_BASE}/deployments/${id} \
&& echo "ok"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment