From 91cbf353396470007e29900d8b813d13360761c7 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 30 Jun 2023 16:01:19 +0300 Subject: [PATCH] Add backport GitHub Action workflow Signed-off-by: Stefan Prodan --- .github/dependabot.yaml | 4 ++-- .github/labels.yaml | 22 ++++++++++++++++++++ .github/workflows/backport.yaml | 32 ++++++++++++++++++++++++++++++ .github/workflows/sync-labels.yaml | 28 ++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 .github/labels.yaml create mode 100644 .github/workflows/backport.yaml create mode 100644 .github/workflows/sync-labels.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 6e4be739..9e16176a 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -3,7 +3,7 @@ version: 2 updates: - package-ecosystem: "github-actions" directory: "/" - labels: ["area/build"] + labels: ["area/ci", "dependencies"] schedule: - # by default this will be on a monday. + # By default, this will be on a monday. interval: "weekly" diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 00000000..92152c1b --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,22 @@ +# Configuration file to declaratively configure labels +# Ref: https://github.com/EndBug/label-sync#Config-files + +- name: area/kustomize + description: Kustomize related issues and PRs + color: '#00e54d' +- name: area/kstatus + description: Health checking related issues and PRs + color: '#25D5CA' + aliases: ['area/health-checks'] +- name: area/sops + description: SOPS related issues and PRs + color: '#FEE5D1' +- name: area/server-side-apply + description: SSA related issues and PRs + color: '#2819CB' +- name: area/varsub + description: Post-build variable substitution related issues and PRs + color: '#8D195D' +- name: backport:release/v1.0.x + description: To be backported to release/v1.0.x + color: '#ffd700' diff --git a/.github/workflows/backport.yaml b/.github/workflows/backport.yaml new file mode 100644 index 00000000..55c1fd1d --- /dev/null +++ b/.github/workflows/backport.yaml @@ -0,0 +1,32 @@ +name: backport + +on: + pull_request_target: + types: [closed, labeled] + +permissions: + contents: read + +jobs: + pull-request: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + if: github.event.pull_request.state == 'closed' && github.event.pull_request.merged && (github.event_name != 'labeled' || startsWith('backport:', github.event.label.name)) + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Create backport PRs + uses: korthout/backport-action@bf5fdd624b35f95d5b85991a728bd5744e8c6cf2 # v1.3.1 + # xref: https://github.com/korthout/backport-action#inputs + with: + # Match labels with a pattern `backport:` + label_pattern: '^backport:([^ ]+)$' + # A bit shorter pull-request title than the default + pull_title: '[${target_branch}] ${pull_title}' + # Simpler PR description than default + pull_description: |- + Automated backport to `${target_branch}`, triggered by a label in #${pull_number}. diff --git a/.github/workflows/sync-labels.yaml b/.github/workflows/sync-labels.yaml new file mode 100644 index 00000000..f0688a42 --- /dev/null +++ b/.github/workflows/sync-labels.yaml @@ -0,0 +1,28 @@ +name: sync-labels +on: + workflow_dispatch: + push: + branches: + - main + paths: + - .github/labels.yaml + +permissions: + contents: read + +jobs: + labels: + name: Run sync + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: EndBug/label-sync@da00f2c11fdb78e4fae44adac2fdd713778ea3e8 # v2.3.2 + with: + # Configuration file + config-file: | + https://raw.githubusercontent.com/fluxcd/community/main/.github/standard-labels.yaml + .github/labels.yaml + # Strictly declarative + delete-other-labels: true