-
Notifications
You must be signed in to change notification settings - Fork 170
98 lines (82 loc) · 3.16 KB
/
linux-next-sync.yml
File metadata and controls
98 lines (82 loc) · 3.16 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: linux-next sync
on:
push:
branches:
- linux-next-sync
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
concurrency:
group: linux-next-sync
cancel-in-progress: false
permissions:
contents: write
jobs:
sync-linux-next:
if: ${{ github.repository == 'kernel-patches/bpf' }}
runs-on: ubuntu-slim
steps:
- name: Clone kernel-patches/bpf (blobless)
shell: bash
run: |
set -euo pipefail
git clone \
--filter=blob:none \
--no-checkout \
--single-branch \
https://github.com/kernel-patches/bpf.git \
repo
- name: Configure git identity
working-directory: repo
shell: bash
run: |
git config user.name 'bpf-ci[bot]'
git config user.email 'bot+bpf-ci@kernel.org'
- name: Sync linux-next branch
working-directory: repo
shell: bash
run: |
set -euo pipefail
BASE_BRANCH='bpf_base'
HEAD_BRANCH='linux-next'
UPSTREAM_REMOTE='linux-next-upstream'
UPSTREAM_URL='https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git'
UPSTREAM_BRANCH='master'
git remote add "${UPSTREAM_REMOTE}" "${UPSTREAM_URL}"
git config "remote.${UPSTREAM_REMOTE}.promisor" true
git config "remote.${UPSTREAM_REMOTE}.partialclonefilter" blob:none
git fetch --no-tags origin \
"+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"
git fetch --no-tags --filter=blob:none "${UPSTREAM_REMOTE}" \
"+refs/heads/${UPSTREAM_BRANCH}:refs/remotes/${UPSTREAM_REMOTE}/${UPSTREAM_BRANCH}"
if git ls-remote --exit-code --heads origin "${HEAD_BRANCH}" >/dev/null 2>&1; then
git fetch --no-tags origin \
"+refs/heads/${HEAD_BRANCH}:refs/remotes/origin/${HEAD_BRANCH}"
fi
git checkout -B "${HEAD_BRANCH}" "refs/remotes/origin/${BASE_BRANCH}"
git merge --no-ff --no-edit "refs/remotes/${UPSTREAM_REMOTE}/${UPSTREAM_BRANCH}"
- name: Generate GitHub App token
if: ${{ github.repository == 'kernel-patches/bpf' }}
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.KPD_BOT_APP_ID }}
private-key: ${{ secrets.KPD_BOT_PRIVATE_KEY }}
- name: Push linux-next branch
if: ${{ github.repository == 'kernel-patches/bpf' }}
working-directory: repo
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
shell: bash
run: |
set -euo pipefail
HEAD_BRANCH='linux-next'
PUSH_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/kernel-patches/bpf.git"
if git show-ref --verify --quiet "refs/remotes/origin/${HEAD_BRANCH}"; then
old_head=$(git rev-parse "refs/remotes/origin/${HEAD_BRANCH}")
git push \
--force-with-lease="refs/heads/${HEAD_BRANCH}:${old_head}" \
"${PUSH_URL}" HEAD:"refs/heads/${HEAD_BRANCH}"
else
git push "${PUSH_URL}" HEAD:"refs/heads/${HEAD_BRANCH}"
fi