github.com/crossplane/upjet@v1.3.0/.github/workflows/commands.yml (about)

     1  # SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io>
     2  #
     3  # SPDX-License-Identifier: CC0-1.0
     4  
     5  name: Comment Commands
     6  
     7  on: issue_comment
     8  
     9  jobs:
    10    points:
    11      runs-on: ubuntu-20.04
    12      if: startsWith(github.event.comment.body, '/points')
    13  
    14      steps:
    15        - name: Extract Command
    16          id: command
    17          uses: xt0rted/slash-command-action@v1
    18          with:
    19            repo-token: ${{ secrets.GITHUB_TOKEN }}
    20            command: points
    21            reaction: "true"
    22            reaction-type: "eyes"
    23            allow-edits: "false"
    24            permission-level: write
    25        - name: Handle Command
    26          uses: actions/github-script@v4
    27          env:
    28            POINTS: ${{ steps.command.outputs.command-arguments }}
    29          with:
    30            github-token: ${{ secrets.GITHUB_TOKEN }}
    31            script: |
    32              const points = process.env.POINTS
    33  
    34              if (isNaN(parseInt(points))) {
    35                console.log("Malformed command - expected '/points <int>'")
    36                github.reactions.createForIssueComment({
    37                  owner: context.repo.owner,
    38                  repo: context.repo.repo,
    39                  comment_id: context.payload.comment.id,
    40                  content: "confused"
    41                })
    42                return
    43              }
    44              const label = "points/" + points
    45  
    46              // Delete our needs-points-label label.
    47              try {
    48                await github.issues.deleteLabel({
    49                  issue_number: context.issue.number,
    50                  owner: context.repo.owner,
    51                  repo: context.repo.repo,
    52                  name: ['needs-points-label']
    53                })
    54                console.log("Deleted 'needs-points-label' label.")
    55              }
    56              catch(e) {
    57                console.log("Label 'needs-points-label' probably didn't exist.")
    58              }
    59  
    60              // Add our points label.
    61              github.issues.addLabels({
    62                issue_number: context.issue.number,
    63                owner: context.repo.owner,
    64                repo: context.repo.repo,
    65                labels: [label]
    66              })
    67              console.log("Added '" + label + "' label.")
    68  
    69    # NOTE(negz): See also backport.yml, which is the variant that triggers on PR
    70    # merge rather than on comment.
    71    backport:
    72      runs-on: ubuntu-20.04
    73      if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport')
    74      steps:
    75        - name: Extract Command
    76          id: command
    77          uses: xt0rted/slash-command-action@v1
    78          with:
    79            repo-token: ${{ secrets.GITHUB_TOKEN }}
    80            command: backport
    81            reaction: "true"
    82            reaction-type: "eyes"
    83            allow-edits: "false"
    84            permission-level: write
    85  
    86        - name: Checkout
    87          uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3
    88          with:
    89            fetch-depth: 0
    90  
    91        - name: Open Backport PR
    92          uses: zeebe-io/backport-action@v0.0.4
    93          with:
    94            github_token: ${{ secrets.GITHUB_TOKEN }}
    95            github_workspace: ${{ github.workspace }}
    96            version: v0.0.4