forked from melpa/melpa
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.33 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
name: Merge the upstream
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * 5'
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
sparse-checkout: '.'
ref: akirak
- name: Switch to a work branch
id: start
run: |
git switch -C upstream-recipes
echo "rev=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Fetch the upstream
id: upstream
run: |
git remote add upstream https://github.com/melpa/melpa.git
git fetch upstream master
echo "ref=upstream/master" >> "$GITHUB_OUTPUT"
- uses: DeterminateSystems/nix-installer-action@v4
with:
diagnostic-endpoint: ''
- 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 ${{ steps.upstream.outputs.ref }} ${{ steps.start.outputs.rev }})
echo "rev=$rev" >> "$GITHUB_OUTPUT"
- name: Filter commits
run: |
tmp="recipes-$(date +%s)"
git switch -c "$tmp" ${{ steps.upstream.outputs.ref }}
nix run nixpkgs#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
# A workaround to prevent peter-evans/create-pull-request from resetting the
# head here:
# <https://github.com/peter-evans/create-pull-request/blob/d806186ee3288c60a352af9852b6b18afbbfd87e/src/create-or-update-branch.ts#L178>
- name: Detach the head
run: git switch --detach `git rev-parse HEAD`
- name: Create a pull request
uses: peter-evans/create-pull-request@v5
with:
base: ${{ steps.merge-base.outputs.rev }}
token: ${{ secrets.PAT_FOR_PR }}
title: 'Merge the upstream recipe commits'
branch: create-pull-request/merge-recipes
labels: automation