github.com/hernad/nomad@v1.6.112/.github/workflows/backport.yml (about)

     1  ---
     2  name: Backport Assistant Runner
     3  
     4  on:
     5    pull_request_target:
     6      types:
     7        - closed
     8        - labeled
     9  
    10  jobs:
    11    backport:
    12      if: github.event.pull_request.merged
    13      runs-on: ubuntu-latest
    14      container: hashicorpdev/backport-assistant:0.2.3
    15      steps:
    16        - name: Backport changes to stable-website
    17          run: |
    18            backport-assistant backport -merge-method=squash -automerge
    19          env:
    20            BACKPORT_LABEL_REGEXP: "backport/(?P<target>website)"
    21            BACKPORT_TARGET_TEMPLATE: "stable-{{.target}}"
    22            # Enabling this option increased the number of backport failures.
    23            BACKPORT_MERGE_COMMIT: false
    24            GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
    25        - name: Backport changes to targeted release branch
    26          run: |
    27            backport-assistant backport -merge-method=squash -automerge
    28          env:
    29            BACKPORT_LABEL_REGEXP: "backport/(?P<target>\\d+\\.\\d+\\.[+\\w]+)"
    30            BACKPORT_TARGET_TEMPLATE: "release/{{.target}}"
    31            # Enabling this option increased the number of backport failures.
    32            BACKPORT_MERGE_COMMIT: false
    33            GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
    34  
    35    handle-failure:
    36      needs:
    37        - backport
    38      if: always() && needs.backport.result == 'failure'
    39      runs-on: ${{ endsWith(github.repository, '-enterprise') && fromJSON('["self-hosted", "ondemand", "linux"]') || 'ubuntu-latest' }}
    40      steps:
    41        - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
    42        - uses: ./.github/actions/vault-secrets
    43          with:
    44            paths: |-
    45              kv/data/teams/nomad/slack-webhooks feed-nomad | SLACK_FEED_NOMAD ;
    46        - name: Send slack notification on failure
    47          uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 # v1.23.0
    48          with:
    49            payload: |
    50              {
    51                "text": ":x::arrow_right_hook::nomad-sob: Backport run *FAILED*",
    52                "attachments": [
    53                  {
    54                    "color": "#C41E3A",
    55                    "blocks": [
    56                      {
    57                        "type": "section",
    58                        "fields": [
    59                          {
    60                            "type": "mrkdwn",
    61                            "text": "*Pull Request:*\n<${{ github.event.pull_request.html_url}}|${{ github.repository }}#${{ github.event.pull_request.number}}>"
    62                          },
    63                          {
    64                            "type": "mrkdwn",
    65                            "text": "*From:*\n@${{ github.event.sender.login }}"
    66                          },
    67                          {
    68                            "type": "mrkdwn",
    69                            "text": "*Run:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>"
    70                          }
    71                        ]
    72                      }
    73                    ]
    74                  }
    75                ]
    76              }
    77          env:
    78            SLACK_WEBHOOK_URL: ${{ env.SLACK_FEED_NOMAD || secrets.BACKPORT_ASSISTANT_FAILURE_SLACK }}
    79            SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
    80  permissions:
    81    contents: read
    82    id-token: write