github.com/kubevela/workflow@v0.6.0/.github/workflows/issue-commands.yml (about)

     1  name: Run commands when issues are labeled or comments added
     2  on:
     3    issues:
     4      types: [labeled, opened]
     5    issue_comment:
     6      types: [created]
     7  
     8  jobs:
     9    bot:
    10      runs-on: ubuntu-20.04
    11      steps:
    12        - name: Checkout Actions
    13          uses: actions/checkout@v2
    14          with:
    15            repository: "oam-dev/kubevela-github-actions"
    16            path: ./actions
    17            ref: v0.4.2
    18        - name: Setup Node.js
    19          uses: actions/setup-node@v3
    20          with:
    21            node-version: '14'
    22            cache: 'npm'
    23            cache-dependency-path: ./actions/package-lock.json
    24        - name: Install Dependencies
    25          run: npm ci --production --prefix ./actions
    26        - name: Run Commands
    27          uses: ./actions/commands
    28          with:
    29            token: ${{secrets.GITHUB_TOKEN}}
    30            configPath: issue-commands
    31  
    32    backport:
    33      runs-on: ubuntu-22.04
    34      if: github.event.issue.pull_request && contains(github.event.comment.body, '/backport')
    35      steps:
    36        - name: Extract Command
    37          id: command
    38          uses: xt0rted/slash-command-action@v1
    39          with:
    40            repo-token: ${{ secrets.GITHUB_TOKEN }}
    41            command: backport
    42            reaction: "true"
    43            reaction-type: "eyes"
    44            allow-edits: "false"
    45            permission-level: read
    46        - name: Handle Command
    47          uses: actions/github-script@v4
    48          env:
    49            VERSION: ${{ steps.command.outputs.command-arguments }}
    50          with:
    51            github-token: ${{ secrets.GITHUB_TOKEN }}
    52            script: |
    53              const version = process.env.VERSION
    54              let label = "backport release-" + version
    55              if (version.includes("release")) {
    56                label = "backport " + version
    57              }
    58              // Add our backport label.
    59              github.issues.addLabels({
    60                // Every pull request is an issue, but not every issue is a pull request.
    61                issue_number: context.issue.number,
    62                owner: context.repo.owner,
    63                repo: context.repo.repo,
    64                labels: [label]
    65              })
    66              console.log("Added '" + label + "' label.")
    67        - name: Checkout
    68          uses: actions/checkout@v3
    69          with:
    70            fetch-depth: 0
    71        - name: Open Backport PR
    72          uses: zeebe-io/backport-action@v0.0.8
    73          with:
    74            github_token: ${{ secrets.GITHUB_TOKEN }}
    75            github_workspace: ${{ github.workspace }}