-
Notifications
You must be signed in to change notification settings - Fork 5.2k
111 lines (102 loc) · 4.06 KB
/
arm-auto-signoff-preview.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: ARM Auto Signoff (Preview)
on:
issue_comment:
types:
- edited
pull_request:
types:
# Depends on labels, so must re-evaluate whenever a relevant label is manually added or removed.
- labeled
- unlabeled
workflow_run:
workflows: ["ARM Incremental Typespec (Preview)"]
types: [completed]
# For manual testing
workflow_dispatch:
inputs:
owner:
description: The account owner of the repository. The name is not case sensitive.
required: true
type: string
repo:
description: The name of the repository without the .git extension. The name is not case sensitive.
required: true
type: string
issue_number:
description: The number of the pull request.
required: true
type: string
head_sha:
description: The SHA of the commit.
required: true
type: string
permissions:
actions: read
checks: read
contents: read
issues: read
pull-requests: read
jobs:
arm-auto-signoff-preview:
name: ARM Auto Signoff (Preview)
# pull_request:labeled - filter to only the input and output labels
# issue_comment:edited - filter to only PR comments containing "next steps to merge",
# a signal that "Swagger LintDiff" status may have changed
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'workflow_run' ||
(github.event_name == 'pull_request' &&
(github.event.action == 'labeled' ||
github.event.action == 'unlabeled') &&
(github.event.label.name == 'ARMReview' ||
github.event.label.name == 'NotReadyForARMReview' ||
github.event.label.name == 'SuppressionReviewRequired' ||
github.event.label.name == 'Approved-Suppression' ||
github.event.label.name == 'ARMAutoSignOffPreview')) ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, 'next steps to merge'))
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
# Only needs .github folder for automation, not the files in the PR (analyzed in a separate workflow)
sparse-checkout: |
.github
# Output:
# {
# labelAction: LabelAction, ("none" for no-op, "add" to add label, and "remove" to remove label)
# issueNumber: number
# }
- id: get-label-action
name: ARM Auto Signoff (Preview)
uses: actions/github-script@v7
with:
script: |
const { default: getLabelAction } =
await import('${{ github.workspace }}/.github/workflows/src/arm-auto-signoff-preview.js');
return await getLabelAction({ github, context, core });
env:
OWNER: ${{ inputs.owner }}
REPO: ${{ inputs.repo }}
ISSUE_NUMBER: ${{ inputs.issue_number }}
HEAD_SHA: ${{ inputs.head_sha }}
- if: |
fromJson(steps.get-label-action.outputs.result).labelAction == 'add' ||
fromJson(steps.get-label-action.outputs.result).labelAction == 'remove'
name: Upload artifact with results
uses: ./.github/actions/add-label-artifact
with:
name: "ARMAutoSignoffPreview"
# Convert "add/remove" to "true/false"
value: "${{ fromJson(steps.get-label-action.outputs.result).labelAction == 'add' }}"
# Required for consumers to identify the PR associated with this workflow run
# Output can be trusted, because it was uploaded from a workflow that is trusted,
# because "issue_comment" and "workflow_run" only trigger on workflows in the default branch.
# Consumers should verify the "event_name" before attempting to extract from the artifact name
- if: ${{ github.event_name == 'issue_comment' || github.event_name == 'workflow_run' }}
name: Upload artifact with issue number
uses: ./.github/actions/add-empty-artifact
with:
name: "issue-number"
value: "${{ fromJson(steps.get-label-action.outputs.result).issueNumber }}"