xref: /llvm-project/.github/workflows/issue-release-workflow.yml (revision 89b83d2d3f2ae7b806987143167e8ccb79c6d674)
1daf82a51STom Stellard# This contains the workflow definitions that allow users to test backports
2daf82a51STom Stellard# to the release branch using comments on issues.
3daf82a51STom Stellard#
4daf82a51STom Stellard# /cherry-pick <commit> <...>
5daf82a51STom Stellard#
6daf82a51STom Stellard# This comment will attempt to cherry-pick the given commits to the latest
77e5f75aaSMohammed Keyvanzadeh# release branch (release/Y.x) and if successful, push the result to a branch
8daf82a51STom Stellard# on github.
9daf82a51STom Stellard#
10daf82a51STom Stellard# /branch <owner>/<repo>/<branch>
11daf82a51STom Stellard#
12daf82a51STom Stellard# This comment will create a pull request from <branch> to the latest release
13daf82a51STom Stellard# branch.
14daf82a51STom Stellard
15daf82a51STom Stellardname: Issue Release Workflow
16daf82a51STom Stellard
17829b8912SJoyce Brumpermissions:
18829b8912SJoyce Brum  contents: read
19829b8912SJoyce Brum
20daf82a51STom Stellardon:
21daf82a51STom Stellard  issue_comment:
22daf82a51STom Stellard    types:
23daf82a51STom Stellard      - created
24daf82a51STom Stellard      - edited
25fee491a1STom Stellard  issues:
26fee491a1STom Stellard    types:
27fee491a1STom Stellard      - opened
28daf82a51STom Stellard
29daf82a51STom Stellardenv:
30fee491a1STom Stellard  COMMENT_BODY: ${{ github.event.action == 'opened' && github.event.issue.body || github.event.comment.body  }}
31daf82a51STom Stellard
32daf82a51STom Stellardjobs:
33daf82a51STom Stellard  backport-commits:
34daf82a51STom Stellard    name: Backport Commits
35d30b187fSMohammed Keyvanzadeh    runs-on: ubuntu-latest
365db2e580SNikita Popov    permissions:
375db2e580SNikita Popov      issues: write
38e99edf6bSTom Stellard      pull-requests: write
39daf82a51STom Stellard    if: >-
40daf82a51STom Stellard      (github.repository == 'llvm/llvm-project') &&
41daf82a51STom Stellard      !startswith(github.event.comment.body, '<!--IGNORE-->') &&
42fee491a1STom Stellard      contains(github.event.action == 'opened' && github.event.issue.body || github.event.comment.body, '/cherry-pick')
43daf82a51STom Stellard    steps:
44daf82a51STom Stellard      - name: Fetch LLVM sources
456d2aaa5fSMarc Auberer        uses: actions/checkout@v4
46daf82a51STom Stellard        with:
47daf82a51STom Stellard          repository: llvm/llvm-project
489bbe44fbSTom Stellard          # GitHub stores the token used for checkout and uses it for pushes
499bbe44fbSTom Stellard          # too, but we want to use a different token for pushing, so we need
509bbe44fbSTom Stellard          # to disable persist-credentials here.
519bbe44fbSTom Stellard          persist-credentials: false
52daf82a51STom Stellard          fetch-depth: 0
53daf82a51STom Stellard
54daf82a51STom Stellard      - name: Setup Environment
55daf82a51STom Stellard        run: |
56*89b83d2dSTom Stellard          pip install --require-hashes -r ./llvm/utils/git/requirements.txt
57daf82a51STom Stellard          ./llvm/utils/git/github-automation.py --token ${{ github.token }} setup-llvmbot-git
58daf82a51STom Stellard
59daf82a51STom Stellard      - name: Backport Commits
60daf82a51STom Stellard        run: |
61859e6aa1SMohammed Keyvanzadeh          printf "%s" "$COMMENT_BODY" |
62daf82a51STom Stellard          ./llvm/utils/git/github-automation.py \
63859e6aa1SMohammed Keyvanzadeh          --repo "$GITHUB_REPOSITORY" \
64d2c81673STom Stellard          --token "${{ secrets.RELEASE_WORKFLOW_PR_CREATE }}" \
65daf82a51STom Stellard          release-workflow \
66f03a60d4SNikita Popov          --branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
67daf82a51STom Stellard          --issue-number ${{ github.event.issue.number }} \
680be1c3b9STom Stellard          --requested-by ${{ (github.event.action == 'opened' && github.event.issue.user.login) || github.event.comment.user.login }} \
69daf82a51STom Stellard          auto
70