Skip to content

Commit 7a651e9

Browse files
authored
Merge pull request #406 from fluxcd/backport-automation
Add backport GitHub Action workflow
2 parents 6579af0 + 5a1ccef commit 7a651e9

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

.github/dependabot.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
updates:
44
- package-ecosystem: "github-actions"
55
directory: "/"
6-
labels: ["area/build"]
6+
labels: ["area/ci", "dependencies"]
77
schedule:
8-
# by default this will be on a monday.
8+
# By default, this will be on a monday.
99
interval: "weekly"

.github/labels.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Configuration file to declaratively configure labels
2+
# Ref: https://github.com/EndBug/label-sync#Config-files
3+
4+
# TODO: enable this when we have a release/v1.0.x branch
5+
#- name: backport:release/v1.0.x
6+
# description: To be backported to release/v1.0.x
7+
# color: '#ffd700'

.github/workflows/backport.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: backport
2+
3+
on:
4+
pull_request_target:
5+
types: [closed, labeled]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
pull-request:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
if: github.event.pull_request.state == 'closed' && github.event.pull_request.merged && (github.event_name != 'labeled' || startsWith('backport:', github.event.label.name))
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
20+
with:
21+
ref: ${{ github.event.pull_request.head.sha }}
22+
- name: Create backport PRs
23+
uses: korthout/backport-action@bf5fdd624b35f95d5b85991a728bd5744e8c6cf2 # v1.3.1
24+
# xref: https://github.com/korthout/backport-action#inputs
25+
with:
26+
# Match labels with a pattern `backport:<target-branch>`
27+
label_pattern: '^backport:([^ ]+)$'
28+
# A bit shorter pull-request title than the default
29+
pull_title: '[${target_branch}] ${pull_title}'
30+
# Simpler PR description than default
31+
pull_description: |-
32+
Automated backport to `${target_branch}`, triggered by a label in #${pull_number}.

.github/workflows/sync-labels.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: sync-labels
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- .github/labels.yaml
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
labels:
15+
name: Run sync
16+
runs-on: ubuntu-latest
17+
permissions:
18+
issues: write
19+
steps:
20+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
21+
- uses: EndBug/label-sync@da00f2c11fdb78e4fae44adac2fdd713778ea3e8 # v2.3.2
22+
with:
23+
# Configuration file
24+
config-file: |
25+
https://raw.githubusercontent.com/fluxcd/community/main/.github/standard-labels.yaml
26+
.github/labels.yaml
27+
# Strictly declarative
28+
delete-other-labels: true

0 commit comments

Comments
 (0)