name: Update PyTorch Labels in S3

on:
  label:
  workflow_dispatch:

concurrency:
  group: 1
  cancel-in-progress: true

jobs:
  update-labels-in-S3:
    runs-on: ubuntu-22.04
    if: ${{ github.repository == 'pytorch/pytorch' }}
    permissions:
      id-token: write
      contents: read
    steps:
      - name: Checkout PyTorch
        uses: pytorch/pytorch/.github/actions/checkout-pytorch@release/2.8
        with:
          fetch-depth: 1
          submodules: false
      - name: configure aws credentials
        id: aws_creds
        uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
        with:
          role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_update_pytorch_labels
          aws-region: us-east-1
      - name: Update PyTorch labels list in S3
        run: |
          python3 -m pip install boto3==1.35.42
          .github/scripts/export_pytorch_labels.py pytorch pytorch
