Skip to content

Commit

Permalink
- try to reference my action
Browse files Browse the repository at this point in the history
  • Loading branch information
KinNeko-De committed Aug 3, 2024
1 parent 4769a4a commit 7f9b579
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,7 @@ jobs:
sha: context.sha
})
- name: Delete Git Tags
uses: actions/github-script@v7
uses: KinNeko-De/cleanup-outdated-tag-action/[email protected]
if: github.ref == 'refs/heads/main'
with:
script: |
const existingFeatureBranches = (await github.rest.repos.listBranches({
owner: context.repo.owner,
repo: context.repo.repo,
})).data.map(branch => branch.name);
console.log("Existing feature branches:", existingFeatureBranches);
const tags = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/v',
});
for (const tag of tags.data) {
const tagName = tag.ref.replace('refs/tags/', '');
console.log("Tag:", tagName);
const tagParts = /^v[0-9]*\.[0-9]*\.[0-9]*-(.*)\.([0-9]*)$/.exec(tagName);
if (tagParts) {
const featureBranchName = tagParts[1];
console.log("Feature branch name:", featureBranchName);
if (!existingFeatureBranches.includes(`feature/${featureBranchName}`)) {
console.log(`Branch ${featureBranchName} does not exist, so deleting tag ${tagName}`);
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tagName}`,
});
} else {
console.log(`Branch ${featureBranchName} exists, so not deleting tag ${tagName}`);
}
}
}
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7f9b579

Please sign in to comment.