forked from bromite/bromite
-
Notifications
You must be signed in to change notification settings - Fork 87
154 lines (130 loc) · 4.55 KB
/
check-git-apply.yaml
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Check git apply
permissions:
# actions: none
# checks: none
# contents: write
# deployments: none
# issues: none
# packages: none
pull-requests: write
# repository-projects: none
# security-events: none
# statuses: none
on:
push:
branches-ignore:
- 'ci'
paths:
- 'build/**'
workflow_dispatch:
inputs:
rtag:
description: 'uazo/cromite TAG or COMMIT'
required: true
default: ''
env:
RTAG: ${{ github.event.inputs.rtag }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Get value from dispatch"
run: |
if [ -z "${RTAG}" ]; then
echo "RTAG=$GITHUB_SHA" >> $GITHUB_ENV
echo "RTAG=$RTAG"
fi
- name: Prepare container
run: |
sudo apt update
sudo apt install -y wget unzip tar sed dos2unix patchutils wiggle curl
wget https://github.com/uazo/superpatch/releases/latest/download/SuperPatchUtils.tar.gz
tar xfz SuperPatchUtils.tar.gz
rm SuperPatchUtils.tar.gz
wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip
unzip pup_v0.4.0_linux_amd64.zip
rm pup_v0.4.0_linux_amd64.zip
BRANCH=$(curl https://github.com/uazo/cromite/branch_commits/$RTAG | ./pup -p li.branch:last-child a text{})
if [ -z "${BRANCH}" ]; then
BRANCH=$(curl https://github.com/uazo/cromite/branch_commits/$RTAG a | ./pup -p li.branch:first-child a text{})
fi
if [ -z "${BRANCH}" ]; then
echo "Can not recover the base commit"
exit 1
fi
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Checkout 'uazo/cromite' ${{ env.BRANCH }}
uses: actions/checkout@v2
with:
repository: 'uazo/cromite'
ref: ${{ github.event.inputs.rtag }}
path: 'cromite'
fetch-depth: 1
- name: Check chromium version
run: |
export HOME=$GITHUB_WORKSPACE
VERSION=$(cat ~/cromite/build/RELEASE)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Cache chromium sources
uses: actions/cache@v3
with:
path: chromium-src
key: chrsource-${{ env.VERSION }}
- name: Download chromium ${{ env.VERSION }} sources
run: |
export HOME=$GITHUB_WORKSPACE
./bin/SuperPatchUtils bromite $RTAG ~/chromium-src
mkdir -p ~/chromium/src && cp -rT ~/chromium-src ~/chromium/src
cd ~/chromium/src
git init
git config user.email "[email protected]"
git config user.name "Your Name"
git add .
git commit -m $VERSION
git tag -a $VERSION -m $VERSION
git add -f v8 && git commit -m ":NOEXPORT: v8" || true
- name: Apply patches ${{ github.event.inputs.rtag }}
run: |
export HOME=$GITHUB_WORKSPACE
cd ~/chromium/src
export SILENT=true
export SKIPAUTOGENERATED=true
bash ~/cromite/tools/apply-all-patch.sh || exit 1
rm -rf ~/cromite/build/patches-new/
rm ~/cromite/build/cromite_patches_list_new.txt
- name: Export patches
run: |
export HOME=$GITHUB_WORKSPACE
cd ~/chromium/src
bash ~/cromite/tools/export-all-patch.sh
cd ~/cromite
rm -rf build/patches/*
mv build/patches-new/* build/patches
rm -rf build/patches-new/
- name: Check differences CHANGES=${{ env.CHANGES }}
run: |
export HOME=$GITHUB_WORKSPACE
cd ~/cromite
CHANGES=0 && git diff --quiet || CHANGES=1
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
if [[ CHANGES -eq 1 ]]; then
git add build/patches/*.patch
git diff --name-only --staged
# MESSAGE=$(git diff --name-only --staged)
# echo "MESSAGE='$MESSAGE'" >> $GITHUB_ENV
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6.1.0
if: env.CHANGES == '1'
with:
token: ${{ secrets.CROMITE_PULLS }}
path: cromite
base: ${{ env.BRANCH }}
#push-to-fork: uazo/cromite
add-paths: |
build/patches/*.patch
commit-message: '[AUTO] Patches auto-rebase'
title: '[AUTO] Patches auto-rebase for ${{ env.BRANCH }} branch'
body: ${{ env.MESSAGE }}
delete-branch: true
branch-suffix: short-commit-hash