-
Notifications
You must be signed in to change notification settings - Fork 221
102 lines (93 loc) · 3.13 KB
/
pull-request-target.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
name: pull-request-target
on:
pull_request_target:
types: [opened, edited, synchronize, labeled, closed]
branches:
- "*"
concurrency:
# Generally we use `github.ref`, but in pull_request_target, that's always `main`.
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
main:
name: Validate PR title
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
# The standard ones plus
# - "internal" for code quality / ergonomics improvements
# - "devops" for developer ergonomics
# - "web" for playground / website (but not docs)
# - "refine" for tiny changes
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
internal
devops
web
refine
backport:
# Backport to `web` branch on `pr-backport-web`
name: Backport to `web` branch
runs-on: ubuntu-22.04
# Confirm that it's merged and has a label to ensure nothing is backported without oversight
if: |
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'pr-backport-web')
)
)
steps:
- uses: tibdex/backport@v2
with:
# This is a personal access token from the @prql-bot
github_token: ${{ secrets.PRQL_BOT_GITHUB_TOKEN }}
# Docs are at https://github.com/tibdex/backport/blob/main/action.yml
# We only use `web` atm
label_pattern: "^pr-backport-(?<base>([^ ]+))$"
title_template: "chore: Backport #<%= number%> to `web`"
automerge:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: write
# Check it's not coming from a fork — both to save running and
# in case someone spoofed an `actor` name.
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
# Get number of commits in the PR
- id: commit-count
run: >
echo "commit-count=$(curl -s -H 'Authorization: token ${{ github.token
}}' https://api.github.com/repos/prql/prql/pulls/${{
github.event.pull_request.number }}/commits | jq 'length')"
>>"$GITHUB_OUTPUT"
- if:
# - It's dependabot
# - or there's only one commit — so nothing has made further changes and
# - or it's prql-bot
# - or it's a pre-commit-ci update
github.actor == 'dependabot[bot]' ||
(steps.commit-count.outputs.commit-count == '1' && (github.actor ==
'prql-bot' || github.actor == 'pre-commit-ci[bot]'))
run:
gh pr merge --auto --squash --delete-branch ${{
github.event.pull_request.html_url }}
env:
GITHUB_TOKEN: ${{ secrets.PRQL_BOT_GITHUB_TOKEN }}