forked from melpa/melpa
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.2 KB
/
merge-upstream.yml
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
name: Merge upstream recipes
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * 5'
jobs:
pr:
runs-on: ubuntu-latest
strategy:
matrix:
base_ref:
- akirak
upstream:
- 'https://github.com/melpa/melpa.git'
upstream_branch:
- 'master'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
sparse-checkout: '.'
ref: ${{ matrix.base_ref }}
- name: Switch to a work branch
id: start
run: |
echo "rev=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Install git-filter-repo
run: |
sudo apt-get update && sudo apt-get install git-filter-repo --yes
- name: Fetch the upstream
run: |
git remote add upstream ${{ matrix.upstream }}
git fetch upstream ${{ matrix.upstream_branch }}
- name: Configure the Git identity
run: |
# Set some identity. Actually it will be overridden later by git-filter-repo,
# so it can be anything
git config --add user.name 'github-actions[bot]'
git config --add user.email '6270544+github-actions[bot]@users.noreply.github.com'
- name: Retrieve the merge base
id: merge-base
run: |
rev=$(git merge-base upstream/${{ matrix.upstream_branch }} ${{ matrix.base_ref }})
echo "rev=$rev" > "$GITHUB_OUTPUT"
- name: Filter commits
run: |
git switch -C upstream-recipes upstream/${{ matrix.upstream_branch }}
git-filter-repo \
--path recipes/ --refs "${{ steps.merge-base.outputs.rev }}..HEAD" \
--commit-callback '
commit.committer_name = commit.author_name
commit.committer_email = commit.author_email
commit.committer_date = commit.author_date
' --force
- name: Cherry-pick the filtered commits
run: |
git switch ${{ matrix.base_ref }}
git cherry-pick --strategy ort -X theirs ..upstream-recipes
- name: Create a pull request
uses: peter-evans/create-pull-request@v5
with:
branch: create-pull-request/recipes
token: ${{ secrets.PAT_FOR_PR }}
title: 'Merge upstream recipe commits'
labels: automation