Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling in case release branch doesn't exist yet #7094

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,22 @@ jobs:
with:
result-encoding: string
script: |
const { data } = await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: '${{ steps.get-version.outputs.release-branch-name }}',
})
try {
const { data } = await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: '${{ steps.get-version.outputs.release-branch-name }}',
})
if (data.name == '${{ steps.get-version.outputs.release-branch-name }}' && context.ref == 'refs/heads/main' && context.eventName == 'push') {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} already exists and this is a push to main.")
return 'true'
} else {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} does not exist or this is not a push to main.")
if (data && data.name == '${{ steps.get-version.outputs.release-branch-name }}' && context.ref == 'refs/heads/main' && context.eventName == 'push') {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} already exists and this is a push to main.")
return 'true'
} else {
console.log("This is not a push to main.")
return 'false'
}
} catch (error) {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} does not exist.")
return 'false'
}
- name: Generate release summary
Expand Down
Loading