Improve API Access Control in AWX #1776
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: Label Issue | |
on: | |
issues: | |
types: | |
- opened | |
- reopened | |
permissions: | |
contents: write # to fetch code | |
issues: write # to label issues | |
jobs: | |
triage: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
name: Label Issue | |
steps: | |
- name: Label Issue | |
uses: github/issue-labeler@v3.1 | |
with: | |
repo-token: "${{ secrets.GITHUB_TOKEN }}" | |
not-before: 2021-12-07T07:00:00Z | |
configuration-path: .github/issue_labeler.yml | |
enable-versioned-regex: 0 | |
community: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
name: Label Issue - Community | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- 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.issue.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 }} |