Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(automerge-sync-pr): trigger workflow with dispatch event from upstream workflow #73

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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