mirror of
https://github.com/nix-community/NixOS-WSL.git
synced 2026-11-07 14:59:35 +00:00
81 lines
2.6 KiB
YAML
81 lines
2.6 KiB
YAML
# Heavily inspired by https://github.com/NixOS/nixpkgs/blob/a698ac1214cd924d4394ca9cd2691618765aa03c/.github/workflows/backport.yml
|
|
|
|
name: "On Backport Label"
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- closed
|
|
- labeled
|
|
|
|
permissions:
|
|
actions: write
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
backport:
|
|
if: github.event.pull_request.labels && contains(join(github.event.pull_request.labels.*.name, ', '), 'backport ')
|
|
name: Backport PR 🔙
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
outputs:
|
|
created_pull_numbers: ${{ steps.backport.outputs.created_pull_numbers }}
|
|
steps:
|
|
- name: Check actor permissions
|
|
id: check-permissions
|
|
uses: prince-chrismc/check-actor-permissions-action@00b85696974a3461836b27f5e17128c65d677a1b # v4.0.0
|
|
with:
|
|
permission: write
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
allow-unsafe-pr-checkout: true
|
|
|
|
- name: Create backport PR
|
|
id: backport
|
|
uses: korthout/backport-action@0ebd44f9c79a4a0a171200dcdcceec3ed9ca732f # v4.7.1
|
|
with:
|
|
merge_commits: "skip"
|
|
add_author_as_assignee: true
|
|
copy_requested_reviewers: true
|
|
|
|
trigger-ci:
|
|
name: Trigger CI on created branches 🚀
|
|
needs: backport
|
|
if: github.event.pull_request.labels && contains(join(github.event.pull_request.labels.*.name, ', '), 'backport ') && needs.backport.outputs.created_pull_numbers != ''
|
|
strategy:
|
|
matrix:
|
|
pr: ${{ fromJSON(format('[{0}]', needs.backport.outputs.created_pull_numbers)) }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Get PR branch
|
|
id: branch
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
echo "branch=$(gh pr view ${{ matrix.pr }} --json headRefName -q .headRefName)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Dispatch workflow
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
with:
|
|
script: |
|
|
github.rest.actions.createWorkflowDispatch({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
workflow_id: 'on_push.yml',
|
|
ref: '${{ steps.branch.outputs.branch }}',
|
|
inputs: {
|
|
pr_number: '${{ matrix.pr }}',
|
|
post_result: 'true'
|
|
}
|
|
})
|