-
Notifications
You must be signed in to change notification settings - Fork 384
79 lines (74 loc) · 3.72 KB
/
inter-branch-merge-base.yml
File metadata and controls
79 lines (74 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This is a workflow file that will be used to merge branches in the repository.
# Permissions required:
# Contents
# write
# Pull requests
# write
# More information on permissions: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
#
# Event data: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call received is equal to the caller event data.
# In order to understand which version of script needs to be used parameter script version introduced, which should be equal to the ref of referenced workflow file.
# More information on the script_version:
# https://github.com/orgs/community/discussions/18601
# https://github.com/orgs/community/discussions/63863
on:
workflow_call:
inputs:
configuration_file_branch:
type: string
description: The branch to read the configuration file from.
required: false
default: 'main'
configuration_file_path:
type: string
description: The path to the configuration file.
required: false
default: 'github-merge-flow.jsonc'
script_version:
type: string
required: false
description: Optional parameter which allows the target repository to use different branch of this shared workflow.
default: 'main'
jobs:
run-merge:
runs-on: windows-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Enable git longpath
run: git config --global core.longpaths true
- name: Checkout caller repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
path: repository
fetch-depth: 0
- name: Checkout arcade repository
uses: actions/checkout@v4
with:
repository: dotnet/arcade
path: arcade-repository
ref: ${{ inputs.script_version }}
sparse-checkout: |
.github
- name: Fetch repository name
id: fetch-repo-name
run: |
$repoName = "${{ github.repository }}"
$repoNameWithoutOwner = $repoName.Substring("${{ github.repository_owner }}".Length + 1)
"repository_name=$repoNameWithoutOwner" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Extract configuration values
id: extract-configuration-values
run: ${{ github.workspace }}\arcade-repository\.github\workflows\scripts\read-configuration.ps1 -ConfigurationFileBranch ${{ inputs.configuration_file_branch }} -RepoName ${{ steps.fetch-repo-name.outputs.repository_name }} -RepoOwner ${{ github.repository_owner }} -MergeFromBranch $env:GITHUB_REF_NAME -ConfigurationFilePath ${{inputs.configuration_file_path}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: Write-Host "Configuration required for running merge flow was not found or was not valid."
if: steps.extract-configuration-values.outputs.configurationFound != 'true'
name: Read configuration status
- run: ${{ github.workspace }}\arcade-repository\.github\workflows\scripts\inter-branch-merge.ps1 -RepoName ${{ steps.fetch-repo-name.outputs.repository_name }} -RepoOwner ${{ github.repository_owner }} -MergeFromBranch $env:GITHUB_REF_NAME -MergeToBranch ${{ steps.extract-configuration-values.outputs.mergeToBranch }} -ResetToTargetPaths "${{ steps.extract-configuration-values.outputs.resetToTargetPaths }}" ${{ steps.extract-configuration-values.outputs.mergeSwitchArguments }}
if: steps.extract-configuration-values.outputs.configurationFound == 'true'
name: Merge branches
working-directory: ${{ github.workspace }}/repository
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}