Skip to content

Commit

Permalink
ci(automerge-sync-pr): trigger workflow with dispatch event from upst…
Browse files Browse the repository at this point in the history
…ream workflow (#73)
  • Loading branch information
sumire88 authored Aug 24, 2024
1 parent fdf670b commit a1fc68b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
37 changes: 15 additions & 22 deletions .github/workflows/automerge-sync-pr.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
name: Auto merge changes made to the target branches in a pull request

on:
pull_request:
types:
- opened
branches:
- unstable
- experiment
workflow_dispatch:
inputs:
pr_number:
description: Pull request number
required: true
type: string

jobs:
sync-changes:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
matrix:
include:
- branch: unstable
labels: branch/unstable
- branch: experiment
labels: branch/experiment
fail-fast: false
steps:
- name: Generate GitHub Auth Token
# https://github.com/tibdex/github-app-token
Expand All @@ -37,12 +29,13 @@ jobs:
uses: pascalgn/automerge-action@main
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
MERGE_LABELS: "automerge"
MERGE_REMOVE_LABELS: "automerge"
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "ci(github-action): auto merge {pullRequest.number}"
MERGE_FORKS: "false"
MERGE_RETRIES: "0"
MERGE_RETRY_SLEEP: "0"
MERGE_REQUIRED_APPROVALS: "0"
MERGE_LABELS: automerge
MERGE_REMOVE_LABELS: automerge
MERGE_METHOD: squash
MERGE_COMMIT_MESSAGE: "ci(github-action): auto merge ${{ inputs.pr_number }}"
MERGE_FORKS: false
MERGE_RETRIES: 0
MERGE_RETRY_SLEEP: 0
MERGE_REQUIRED_APPROVALS: 0
BASE_BRANCHES: "unstable,experiment"
PULL_REQUEST: ${{ inputs.pr_number }}
18 changes: 17 additions & 1 deletion .github/workflows/sync-changes-to-child-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
branch/unstable
automerge
- branch: experiment
labels: branch/experiment
labels: |
branch/experiment
automerge
fail-fast: false
steps:
- name: Generate GitHub Auth Token
Expand Down Expand Up @@ -54,6 +56,7 @@ jobs:
- name: Cherry pick changes into target branch
# https://github.com/carloscastrojumo/github-cherry-pick-action
uses: carloscastrojumo/github-cherry-pick-action@main
id: cherrypick_pr
with:
branch: ${{ matrix.branch }}
labels: |
Expand All @@ -65,3 +68,16 @@ jobs:
cherry-pick-branch: cherrypick-${{ env.COMMIT_SHORT_SHA }}-${{ matrix.branch }}
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- name: Trigger downstream workflow
uses: convictional/[email protected]
with:
owner: ${{ github.repository_owner }}
repo: flake.nix
github_token: ${{ steps.generate_token.outputs.token }}
workflow_file_name: automerge-sync-pr.yml
ref: ${{ github.event.repository.default_branch }}
client_payload: '{"pr_number":"${{ steps.cherrypick_pr.outputs.number }}"}'
trigger_workflow: true
propagate_failure: false
wait_workflow: false

0 comments on commit a1fc68b

Please sign in to comment.