I have a node script that deletes releases and tags from a GitHub repository using Octokit-js.
It works exactly as expected when I run it from a workstation remotely with the necessary environment variables set for the token, owner, and repository.
When I embed it in an action and use either the default token or a repository secret configured with the same token I use from the remote workstation, it enumerates releases but then fails with a 404 when deleting the first one.
Does anyone know what I am doing incorrectly?
import { Octokit } from "@octokit/rest"
const octokit = new Octokit({auth: process.env.GITHUB_TOKEN})
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
const releases = await octokit.rest.repos.listReleases({
owner,
repo,
}).then(
r => r.data
)
for (const release of releases) {
console.log(`Removing release "${release.name}" and tag "${release.tag_name}".`)
await octokit.rest.repos.deleteRelease({
owner,
repo,
release_id: release.id
})
await octokit.rest.git.deleteRef({owner, repo, ref: `tags/${release.tag_name}`})
}