mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
90 lines
2.7 KiB
YAML
90 lines
2.7 KiB
YAML
name: Label PR
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
|
|
permissions:
|
|
contents: write # to determine modified files (actions/labeler)
|
|
pull-requests: write # to add labels to PRs (actions/labeler)
|
|
|
|
jobs:
|
|
triage:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
name: Label PR
|
|
|
|
steps:
|
|
- name: Label PR
|
|
uses: actions/labeler@v3
|
|
with:
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
configuration-path: .github/pr_labeler.yml
|
|
|
|
convert-to-draft:
|
|
runs-on: ubuntu-latest
|
|
name: Change failing PRS to draft
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 14
|
|
|
|
- name: Install dependencies
|
|
run: npm install -g github
|
|
|
|
- name: Check CI status
|
|
id: check-ci
|
|
run: |
|
|
status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/check-suites | \
|
|
jq -r '.check_suites[0].conclusion')
|
|
echo "CI Status: $status"
|
|
echo "::set-output name=ci_status::$status"
|
|
|
|
- name: Convert to Draft on CI Failure
|
|
if: steps.check-ci.outputs.ci_status == 'failure'
|
|
run: gh pr edit ${{ github.event.number }} --draft
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
community:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
name: Label PR - Community
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
- name: Install python requests
|
|
run: pip install requests
|
|
- name: Check if user is a member of Ansible org
|
|
uses: jannekem/run-python-script-action@v1
|
|
id: check_user
|
|
with:
|
|
script: |
|
|
import requests
|
|
headers = {'Accept': 'application/vnd.github+json', 'Authorization': 'token ${{ secrets.GITHUB_TOKEN }}'}
|
|
response = requests.get('${{ fromJson(toJson(github.event.pull_request.user.url)) }}/orgs?per_page=100', headers=headers)
|
|
is_member = False
|
|
for org in response.json():
|
|
if org['login'] == 'ansible':
|
|
is_member = True
|
|
if is_member:
|
|
print("User is member")
|
|
else:
|
|
print("User is community")
|
|
- name: Add community label if not a member
|
|
if: contains(steps.check_user.outputs.stdout, 'community')
|
|
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
|
|
with:
|
|
add-labels: "community"
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|