• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Check whether the workflow owner can use ARC runners
2
3on:
4  workflow_call:
5    inputs:
6      user_name:
7        required: true
8        type: string
9        description: The name of the workflow owner.
10      curr_branch:
11        required: true
12        type: string
13        description: Current branch.
14      issue_number:
15        required: false
16        type: string
17        default: "5132"
18
19    outputs:
20      workflow-type:
21        description: Type of runners to use
22        value: ${{ jobs.runner-determinator.outputs.workflow-type }}
23
24jobs:
25  runner-determinator:
26    runs-on: linux.4xlarge
27    outputs:
28      workflow-type: ${{ steps.set-condition.outputs.workflow-type }}
29    env:
30      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31      ISSUE_NUMBER: ${{ inputs.issue_number }}
32      USERNAME: ${{ inputs.user_name }}
33    steps:
34      - name: Checkout PyTorch
35        uses: pytorch/pytorch/.github/actions/checkout-pytorch@release/2.4
36        with:
37          fetch-depth: 1
38          submodules: true
39
40      - name: Install dependencies
41        run: python3 -m pip install urllib3==1.26.18 PyGithub==2.3.0
42
43      - name: Get the workflow type for the current user
44        id: set-condition
45        run: |
46          curr_branch="${{ inputs.curr_branch }}"
47          echo "Current branch is '$curr_branch'"
48
49          output="$(python3 .github/scripts/get_workflow_type.py \
50            --github-token "$GITHUB_TOKEN" \
51            --github-issue "$ISSUE_NUMBER" \
52            --github-branch "$curr_branch" \
53            --github-user "$USERNAME")"
54
55          echo "Output: '${output}'"
56
57          WORKFLOW_TYPE=$(echo "${output}" | jq -r '.workflow_type')
58          echo "workflow-type=$WORKFLOW_TYPE" >> "$GITHUB_OUTPUT"
59