-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
147 lines (137 loc) · 4.99 KB
/
action.yml
File metadata and controls
147 lines (137 loc) · 4.99 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: gha-mergify-ci
description: The Mergify CI integration with GitHub Actions
author: Mergify
branding:
icon: at-sign
color: blue
inputs:
action:
description: |
The Mergify CI action:
* junit-process: process JUnit XML files with Mergify CI Insights (Upload and Quarantine)
* scopes: detect and upload pull requests scopes to Mergify Merge Queue
* scopes-git-refs: return the base/head git references of the pull request in Merge Queue context
* scopes-upload: upload pull requests scopes to Mergify Merge Queue
* wait-jobs: wait for specified jobs to complete before proceeding
# Backward compat
default: junit-process
token:
description: Mergify CI token
mergify_api_url:
description: URL of the Mergify API
default: https://api.mergify.com
job_name:
description: |
Override the job name, must be used in case of matrix job to avoid
having the same name for all jobs
report_path:
description: Path of the files to upload
scopes:
description: Comma separated list of scopes to upload
mergify_config_path:
description: Path to the Mergify configuration file
jobs:
description: List of jobs to wait for completion
outputs:
scopes:
description: stringified JSON mapping with names of all scopes matching any of changed files
value: ${{ steps.scopes-detection.outputs.scopes }}
base:
description: The Merge Queue aware base sha of the pull request
value: ${{ steps.git-refs-detection.outputs.base || steps.scopes-detection.outputs.base }}
head:
description: The Merge Queue aware head sha of the pull request
value: ${{ steps.git-refs-detection.outputs.head || steps.scopes-detection.outputs.head }}
runs:
using: composite
steps:
- name: Inputs checks
shell: bash
if: |
inputs.action != 'junit-process' &&
inputs.action != 'scopes' &&
inputs.action != 'wait-jobs' &&
inputs.action != 'scopes-git-refs' &&
inputs.action != 'scopes-upload'
env:
ACTION: ${{ inputs.action }}
run: |
echo "Unsupported action: $ACTION"
echo "Valid actions are: junit-process, scopes, scopes-git-refs, scopes-upload, wait-jobs"
exit 1
- name: Setup Python 🔧
uses: actions/setup-python@v6.2.0
with:
python-version: "3.14"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# mergify is too small to benefit + there is no version lock (so no cache key either)
enable-cache: false
- name: Install dependencies
shell: bash
run: |
uv tool install mergify-cli
mergify --version
- shell: bash
id: junit-process
if: inputs.action == 'junit-process'
env:
MERGIFY_API_URL: ${{ inputs.mergify_api_url }}
MERGIFY_TOKEN: ${{ inputs.token }}
MERGIFY_JOB_NAME: ${{ inputs.job_name }}
FILES: ${{ inputs.report_path }}
run: |
set -x -e
mergify ci junit-process ${FILES}
- name: Detect head sha and base sha
if: inputs.action == 'scopes-git-refs' || inputs.action == 'scopes-upload'
id: git-refs-detection
shell: bash
env:
MERGIFY_CONFIG_PATH: ${{ inputs.mergify_config_path }}
run: mergify ci git-refs
- name: Detect scopes, head sha and base sha
if: github.event.pull_request && inputs.action == 'scopes'
id: scopes-detection
shell: bash
env:
MERGIFY_CONFIG_PATH: ${{ inputs.mergify_config_path }}
run: mergify ci scopes --write $RUNNER_TEMP/mergify-scopes.json
- name: Upload scopes to Mergify API
shell: bash
if: github.event.pull_request && inputs.action == 'scopes-upload'
env:
MERGIFY_CONFIG_PATH: ${{ inputs.mergify_config_path }}
SCOPES: ${{ inputs.scopes }}
BASE: ${{ steps.git-refs-detection.outputs.base }}
HEAD: ${{ steps.git-refs-detection.outputs.head }}
run: |
set -euo pipefail
FILE="$RUNNER_TEMP/mergify-scopes.json"
# Convert comma-separated SCOPES into a JSON array
SCOPES_JSON=$(jq -R -s 'rtrimstr("\n") | split(",")' <<< "$SCOPES")
jq -n \
--arg base "$BASE" \
--arg head "$HEAD" \
--argjson scopes "$SCOPES_JSON" \
'{base_ref: $base, head_ref: $head, scopes: $scopes}' > "$FILE"
echo "Created scopes file:"
cat "$FILE"
- name: Upload scopes to Mergify API
shell: bash
if: |
inputs.token &&
github.event.pull_request &&
(inputs.action == 'scopes' || inputs.action == 'scopes-upload')
env:
MERGIFY_TOKEN: ${{ inputs.token }}
MERGIFY_API_URL: ${{ inputs.mergify_api_url }}
MERGIFY_CONFIG_PATH: ${{ inputs.mergify_config_path }}
run: mergify ci scopes-send --file $RUNNER_TEMP/mergify-scopes.json
- name: Wait jobs
if: inputs.action == 'wait-jobs'
uses: re-actors/alls-green@release/v1
with:
allowed-skips: ${{ inputs.jobs }}
jobs: ${{ inputs.jobs }}