-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) According to @bryanboza 's requirements at release time the `Next Release` label should be renamed to the release version one and a new `Next Release` label should be created.
- Loading branch information
1 parent
0b84290
commit f688ff8
Showing
2 changed files
with
126 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: 'Release Labeling' | ||
on: | ||
workflow_call: | ||
secrets: | ||
CI_MACHINE_TOKEN: | ||
description: 'CI machine token' | ||
required: true | ||
inputs: | ||
rename_label: | ||
description: 'Rename label' | ||
type: string | ||
required: false | ||
default: 'Next Release' | ||
new_label: | ||
description: 'New label' | ||
type: string | ||
required: true | ||
workflow_dispatch: | ||
inputs: | ||
rename_label: | ||
description: 'Rename label' | ||
type: string | ||
required: false | ||
default: 'Next Release' | ||
new_label: | ||
description: 'New label' | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
release-labeling: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
REPO: core | ||
steps: | ||
- run: echo 'GitHub context' | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
- name: Rename label | ||
if: success() | ||
id: validate-inputs | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
retries: 3 | ||
retry-exempt-status-codes: 400,401 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
async function getLabel(name) { | ||
console.log(`Getting label [${name}]`); | ||
try { | ||
const response = await github.rest.issues.getLabel({ | ||
owner: '${{ github.repository_owner }}', | ||
repo: '${{ env.REPO }}', | ||
name, | ||
}); | ||
return response.data; | ||
} catch(error) { | ||
console.log(`Error getting label: ${error}`); | ||
return undefined; | ||
} | ||
} | ||
const renameLabel = await getLabel('${{ inputs.rename_label }}'); | ||
if (!renameLabel) { | ||
console.log(`Label [${{ inputs.rename_label }}] not found, skipping rename`); | ||
return; | ||
} | ||
const newLabel = await getLabel('${{ inputs.new_label }}'); | ||
if (newLabel) { | ||
console.log(`Label [${newLabel.name}] already exists, skipping rename`); | ||
return; | ||
} | ||
console.log(`Renaming label [${renameLabel.name}] for owner [${{ github.repository_owner }}] repo [${{ env.REPO }}] with new label [${{ inputs.new_label }}]`); | ||
await github.rest.issues.updateLabel({ | ||
owner: '${{ github.repository_owner }}', | ||
repo: '${{ env.REPO }}', | ||
name: renameLabel.name, | ||
new_name: '${{ inputs.new_label }}' | ||
}); | ||
- name: Re-Create New Label | ||
if: success() | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
retries: 3 | ||
retry-exempt-status-codes: 400,401 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
async function getLabel(name) { | ||
console.log(`Getting label [${name}]`); | ||
try { | ||
const response = await github.rest.issues.getLabel({ | ||
owner: '${{ github.repository_owner }}', | ||
repo: '${{ env.REPO }}', | ||
name, | ||
}); | ||
return response.data; | ||
} catch(error) { | ||
console.log(`Error getting label: ${error}`); | ||
return undefined; | ||
} | ||
} | ||
const renameLabel = await getLabel('${{ inputs.rename_label }}'); | ||
if (renameLabel) { | ||
console.log(`Label [${renameLabel.name}] already exists, skipping re-creation`); | ||
return; | ||
} | ||
console.log(`Recreating label [${{ inputs.rename_label }}] for owner [${{ github.repository_owner }}] repo [${{ env.REPO }}]`); | ||
await github.rest.issues.createLabel({ | ||
owner: '${{ github.repository_owner }}', | ||
repo: '${{ env.REPO }}', | ||
name: '${{ inputs.rename_label }}' | ||
}); |
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