Fix CICD[4] #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Draft Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
draft-release: | |
name: Draft Github Release | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Draft github release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const releases = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: "unreleased", | |
}) | |
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased'); | |
if (filtered.length === 0) { | |
console.log("Creating a new untagged release") | |
await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: "unreleased", | |
name: "Unreleased", | |
draft: true, | |
generate_release_notes: true, | |
}) | |
} else { | |
console.log("Deleting old untagged release") | |
await github.rest.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: filtered[0].id | |
}) | |
console.log("Creating a new untagged release") | |
await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: "unreleased", | |
name: "Unreleased", | |
draft: true, | |
generate_release_notes: true, | |
}) | |
} |