Label to Next Release #29
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
# action.yml | |
name: 'QA not needed update' | |
on: | |
workflow_call: | |
inputs: | |
issue_number: | |
description: 'Issue number' | |
type: number | |
required: true | |
label: | |
description: 'Label' | |
type: string | |
required: true | |
secrets: | |
CI_MACHINE_USER: | |
description: 'CI machine user' | |
required: true | |
CI_MACHINE_TOKEN: | |
description: 'CI machine token' | |
required: true | |
workflow_dispatch: | |
inputs: | |
issue_number: | |
description: 'Issue number' | |
type: number | |
required: true | |
label: | |
description: 'Label' | |
type: string | |
required: true | |
jobs: | |
qa-not-needed-update: | |
runs-on: ubuntu-20.04 | |
env: | |
QA_NOT_NEEDED_LABEL: 'QA : Not Needed' | |
steps: | |
- run: echo 'GitHub context' | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
- name: Validate inputs | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
if ('${{ inputs.issue_number }}'.trim() === '') { | |
console.log('Issue number is not provided'); | |
process.exit(0); | |
} | |
if ('${{ inputs.label }}' !== '${{ env.QA_NOT_NEEDED_LABEL }}') { | |
console.log('Label is not "${{ env.QA_NOT_NEEDED_LABEL }}", exiting'); | |
process.exit(0); | |
} | |
- name: Add Next Release label | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
retries: 3 | |
retry-exempt-status-codes: 400,401 | |
github-token: ${{ secrets.CI_MACHINE_TOKEN }} | |
script: | | |
const issue = await github.rest.issues.get({ | |
issue_number: ${{ inputs.issue_number }}, | |
owner: '${{ github.repository_owner }}', | |
repo: 'core' | |
}); | |
if (!issue) { | |
console.log('Issue [${{ inputs.issue_number }}] not found'); | |
process.exit(0); | |
} | |
console.log(`Issue: ${JSON.stringify(issue, null, 2)}`); | |
const dropAndLearnText = 'Drop Everything & Learn'; | |
if (issue.data.title.includes(dropAndLearnText)) { | |
console.log(`Issue does have "${dropAndLearnText}" text in title, exiting`); | |
process.exit(0); | |
} | |
const typeCicdLabel = 'Type : CI/CD'; | |
const foundLabel = issue.data.labels.find(label => label.name === typeCicdLabel); | |
if (foundLabel) { | |
console.log(`Issue does have "${typeCicdLabel}" label , exiting`); | |
process.exit(0); | |
} | |
await github.rest.issues.addLabels({ | |
issue_number: ${{ inputs.issue_number }}, | |
owner: '${{ github.repository_owner }}', | |
repo: 'core', | |
labels: ['Next Release'] | |
}); | |
const updated = await github.rest.issues.get({ | |
issue_number: ${{ inputs.issue_number }}, | |
owner: '${{ github.repository_owner }}', | |
repo: 'core' | |
}); | |
console.log(`Issue: ${JSON.stringify(updated, null, 2)}`); |