check if repo is public AB#239971 #24
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: Validate Work Item in PR | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, edited] | |
jobs: | |
check-work-item: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Checkout Workflows Repository | |
uses: actions/checkout@v3 | |
with: | |
repository: optimove-tech/workflows | |
path: org-workflows | |
ref: 'main' | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install requests | |
- name: Get PR title | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PULL_REQUEST=$(gh api ${{ github.event.pull_request.url }}) | |
PR_TITLE=$(echo $PULL_REQUEST | jq --raw-output .title | tr '\n' ' ' | tr -d "[]'") | |
#PR_BODY=$(echo $PULL_REQUEST | jq --raw-output .body | tr '\n' ' ' | tr -d "[]'") | |
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV | |
#echo "PR_BODY=$PR_BODY" >> $GITHUB_ENV | |
- name: Check for Work Item in PR Title | |
id: ifLinked | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "PR Title: $PR_TITLE" | |
#echo "PR Body: $PR_BODY" | |
python3 org-workflows/.github/workflows/validate-ado-wi/validate-pattern.py -checklist "['$PR_TITLE']" | |
- name: Check Work Item in PR Title is exist | |
id: ifExists | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ADO_PAT: ${{ secrets.ADO_PAT }} | |
run: | | |
echo "PR Title: $PR_TITLE" | |
#echo "PR Body: $PR_BODY" | |
python3 org-workflows/.github/workflows/validate-ado-wi/validate-wi-exists.py -checklist "['$PR_TITLE']" -organization 'mobius' -project 'Backstage' | |
- name: Ping PR Author to link Work Item | |
if: ${{ failure() && steps.ifLinked.conclusion == 'failure' }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `π Hey @${{ github.event.pull_request.user.login }}, | |
βοΈ Work Item link check failed: There is no Work Item linked to this PR. | |
𧩠Please add the Work Item ID to the PR title using the "Edit" option in the format below: | |
AB#XXXXX - replace X with a valid Work Item ID. | |
π’ Once added, please use "Re-run jobs" in PR check or proceed with "Close pull request" and "Reopen pull request" options below to restart the validation.` | |
}) | |
- name: Ping PR Author to verify Work Item ID | |
if: ${{ failure() && steps.ifExists.conclusion == 'failure' }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `π Hey @${{ github.event.pull_request.user.login }}, | |
πΏ The specified Work Item ID could not be found. | |
π Make sure the Work Item ID exists in the PR title, and correct it using the "Edit" option in the format below: | |
AB#XXXXX - replace X with a valid Work Item ID. | |
π’ Once corrected, please use "Re-run jobs" in PR check or proceed with "Close pull request" and "Reopen pull request" options below to restart the validation.` | |
}) |