ci: handle add device automatically (#157)
This commit is contained in:
2
.github/ISSUE_TEMPLATE/add_device.yml
vendored
2
.github/ISSUE_TEMPLATE/add_device.yml
vendored
@@ -29,5 +29,5 @@ body:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you should be the maintainer of the repository.
|
||||
options:
|
||||
- label: I'am the maintainer of this repository
|
||||
- label: I'm the maintainer of this repository
|
||||
required: true
|
||||
|
||||
59
.github/workflows/add-device.yml
vendored
Normal file
59
.github/workflows/add-device.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: handle-add-device-issue
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
handle-add-device:
|
||||
if: github.event.label.name == 'add-device'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
ISSUE_CONTENT: ${{ github.event.issue.body }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Parse issue body
|
||||
id: handle-add-device
|
||||
run: |
|
||||
python3 scripts/add_device_handler.py website/docs/repos.json || true
|
||||
- name: Commit
|
||||
if: steps.handle-add-device.outputs.success == 'true'
|
||||
run: |
|
||||
git config --local user.name "GitHub Actions"
|
||||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add website/docs/repos.json
|
||||
git commit -m "add device: ${{ steps.handle-add-device.outputs.device }}"
|
||||
- name: Make pull request
|
||||
if: steps.handle-add-device.outputs.success == 'true'
|
||||
id: cpr
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "[add device]: ${{ steps.handle-add-device.outputs.device }}"
|
||||
title: "[add device]: ${{ steps.handle-add-device.outputs.device }}"
|
||||
body: |
|
||||
${{ steps.handle-add-device.outputs.device }} has been added to the website.
|
||||
Related issue: ${{ github.event.issue.html_url }}
|
||||
branch: "add-device-${{ github.event.issue.number }}"
|
||||
labels: add-device
|
||||
delete-branch: true
|
||||
- name: Check outputs
|
||||
if: ${{ steps.cpr.outputs.pull-request-number }}
|
||||
run: |
|
||||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
- uses: ben-z/actions-comment-on-issue@1.0.2
|
||||
if: ${{ steps.cpr.outputs.pull-request-number }}
|
||||
with:
|
||||
message: "Automatically created pull request: ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: ben-z/actions-comment-on-issue@1.0.2
|
||||
if: steps.handle-add-device.outputs.success != 'true'
|
||||
with:
|
||||
message: "Cannot create pull request. Please check the issue content. Or you can create a pull request manually."
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: close issue
|
||||
uses: peter-evans/close-issue@v1
|
||||
with:
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
50
scripts/add_device_handler.py
Normal file
50
scripts/add_device_handler.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
assert len(sys.argv) == 2
|
||||
file_name = sys.argv[1]
|
||||
github = "https://github.com/"
|
||||
issue_content = os.environ["ISSUE_CONTENT"]
|
||||
lines = issue_content.split("\n\n")
|
||||
assert len(lines) == 6
|
||||
url = lines[1]
|
||||
print(url)
|
||||
device = lines[3]
|
||||
print(device)
|
||||
code_of_conduct = lines[5]
|
||||
print(code_of_conduct)
|
||||
assert code_of_conduct.find("[X]") > 0
|
||||
tmp = url.removesuffix("/").replace(github, "").split("/")
|
||||
print(tmp)
|
||||
assert len(tmp) == 2
|
||||
maintainer = tmp[0]
|
||||
print(maintainer)
|
||||
maintainer_link = "%s%s" % (github, maintainer)
|
||||
print(maintainer_link)
|
||||
kernel_name = tmp[1]
|
||||
print(kernel_name)
|
||||
kernel_link = "%s%s/%s" % (github, maintainer, kernel_name)
|
||||
print(kernel_link)
|
||||
with open(file_name, "r") as f:
|
||||
data = json.loads(f.read())
|
||||
data.append(
|
||||
{
|
||||
"maintainer": maintainer,
|
||||
"maintainer_link": maintainer_link,
|
||||
"kernel_name": kernel_name,
|
||||
"kernel_link": kernel_link,
|
||||
"device": device,
|
||||
}
|
||||
)
|
||||
os.remove(file_name)
|
||||
with open(file_name, "w") as f:
|
||||
f.write(json.dumps(data, indent=4))
|
||||
os.system("echo success=true >> $GITHUB_OUTPUT")
|
||||
os.system("echo device=%s >> $GITHUB_OUTPUT" % device)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -9,7 +9,7 @@ This page is only for you to find the source code corresponding to your device,
|
||||
:::
|
||||
|
||||
<script setup>
|
||||
import data from '../repos'
|
||||
import data from '../repos.json'
|
||||
</script>
|
||||
|
||||
<table>
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
const repos = [
|
||||
{
|
||||
maintainer: 'SpectreDev-007',
|
||||
maintainer_link: 'https://github.com/SpectreDev-007',
|
||||
kernel_name: 'kernel_sony_sm8250',
|
||||
kernel_link: 'https://github.com/XperiaBrickers/kernel_sony_sm8250',
|
||||
devices: 'Sony sm8250 device'
|
||||
},
|
||||
|
||||
{
|
||||
maintainer: 'akash07k',
|
||||
maintainer_link: 'https://github.com/akash07k',
|
||||
kernel_name: 'nexus_kernel_xiaomi_sm8250',
|
||||
kernel_link: 'https://github.com/akash07k/nexus_kernel_xiaomi_sm8250/tree/lychee',
|
||||
devices: 'Poco F4: munch'
|
||||
},
|
||||
|
||||
{
|
||||
maintainer: 'HMTheBoy154',
|
||||
maintainer_link: 'https://github.com/hmtheboy154',
|
||||
kernel_name: 'Darkmatter-kernel',
|
||||
kernel_link: 'https://github.com/hmtheboy154/Darkmatter-kernel',
|
||||
devices: 'Generic x86_64 devices running Android-x86'
|
||||
},
|
||||
|
||||
{
|
||||
maintainer: 'Asuka-mio',
|
||||
maintainer_link: 'https://github.com/asuka-mio',
|
||||
kernel_name: 'android_kernel_xiaomi_cas',
|
||||
kernel_link: 'https://github.com/AcmeUI-Devices/android_kernel_xiaomi_cas',
|
||||
devices: 'Mi 10 Ultra: cas'
|
||||
},
|
||||
{
|
||||
maintainer: 'xiaoleGun',
|
||||
maintainer_link: 'https://github.com/xiaoleGun',
|
||||
kernel_name: 'Miku_kernel_xiaomi_wayne',
|
||||
kernel_link: 'https://github.com/Diva-Room/Miku_kernel_xiaomi_wayne',
|
||||
devices: 'wayne'
|
||||
},
|
||||
{
|
||||
maintainer: 'YamazakuraH',
|
||||
maintainer_link: 'https://github.com/YamazakuraH',
|
||||
kernel_name: 'kernel_xiaomi_cepheus',
|
||||
kernel_link: 'https://github.com/169163-Network/kernel_xiaomi_cepheus',
|
||||
devices: 'cepheus for pixel experience'
|
||||
},
|
||||
{
|
||||
maintainer: 'SakuraNotStupid',
|
||||
maintainer_link: 'https://github.com/SakuraNotStupid',
|
||||
kernel_name: 'android_kernel_xiaomi_sdm710',
|
||||
kernel_link: 'https://github.com/SakuraNotStupid/android_kernel_xiaomi_sdm710',
|
||||
devices: 'Xiaomi MI 8 SE(sirius)'
|
||||
},
|
||||
{
|
||||
maintainer: 'Aquarius223(paper)',
|
||||
maintainer_link: 'https://github.com/Aquarius223',
|
||||
kernel_name: 'android_kernel_xiaomi_msm8998',
|
||||
kernel_link: 'https://github.com/sticpaper/android_kernel_xiaomi_msm8998-ksu',
|
||||
devices: 'MI 6 (sagit) and MIX 2 (chiron) for LineageOS'
|
||||
},
|
||||
{
|
||||
maintainer: 'SlackerState',
|
||||
maintainer_link: 'https://github.com/SlackerState',
|
||||
kernel_name: 'android_kernel_xiaomi_sm6150',
|
||||
kernel_link: 'https://github.com/SlackerState/android_kernel_xiaomi_sm6150',
|
||||
devices: 'Redmi K30 4G (phoenix)'
|
||||
},
|
||||
{
|
||||
maintainer: 'RooGhz720',
|
||||
maintainer_link: 'https://github.com/RooGhz720',
|
||||
kernel_name: 'Aghisna_Sweet_Kernel',
|
||||
kernel_link: 'https://github.com/RooGhz720/Aghisna_Sweet_Kernel',
|
||||
devices: 'REDMI NOTE 10 PRO (sweet)'
|
||||
},
|
||||
{
|
||||
maintainer: 'OnlyTomInSecond',
|
||||
maintainer_link: 'https://github.com/onlyTomInSecond/',
|
||||
kernel_name: 'android_kernel_xiaomi_sdm845',
|
||||
kernel_link: 'https://github.com/OnlyTomInSecond/android_kernel_xiaomi_sdm845',
|
||||
device: 'Xiaomi 8 (dipper) for LineageOS',
|
||||
},
|
||||
];
|
||||
|
||||
export default repos;
|
||||
79
website/docs/repos.json
Normal file
79
website/docs/repos.json
Normal file
@@ -0,0 +1,79 @@
|
||||
[
|
||||
{
|
||||
"maintainer": "SpectreDev-007",
|
||||
"maintainer_link": "https://github.com/SpectreDev-007",
|
||||
"kernel_name": "kernel_sony_sm8250",
|
||||
"kernel_link": "https://github.com/XperiaBrickers/kernel_sony_sm8250",
|
||||
"devices": "Sony sm8250 device"
|
||||
},
|
||||
{
|
||||
"maintainer": "akash07k",
|
||||
"maintainer_link": "https://github.com/akash07k",
|
||||
"kernel_name": "nexus_kernel_xiaomi_sm8250",
|
||||
"kernel_link": "https://github.com/akash07k/nexus_kernel_xiaomi_sm8250/tree/lychee",
|
||||
"devices": "Poco F4: munch"
|
||||
},
|
||||
{
|
||||
"maintainer": "HMTheBoy154",
|
||||
"maintainer_link": "https://github.com/hmtheboy154",
|
||||
"kernel_name": "Darkmatter-kernel",
|
||||
"kernel_link": "https://github.com/hmtheboy154/Darkmatter-kernel",
|
||||
"devices": "Generic x86_64 devices running Android-x86"
|
||||
},
|
||||
{
|
||||
"maintainer": "Asuka-mio",
|
||||
"maintainer_link": "https://github.com/asuka-mio",
|
||||
"kernel_name": "android_kernel_xiaomi_cas",
|
||||
"kernel_link": "https://github.com/AcmeUI-Devices/android_kernel_xiaomi_cas",
|
||||
"devices": "Mi 10 Ultra: cas"
|
||||
},
|
||||
{
|
||||
"maintainer": "xiaoleGun",
|
||||
"maintainer_link": "https://github.com/xiaoleGun",
|
||||
"kernel_name": "Miku_kernel_xiaomi_wayne",
|
||||
"kernel_link": "https://github.com/Diva-Room/Miku_kernel_xiaomi_wayne",
|
||||
"devices": "wayne"
|
||||
},
|
||||
{
|
||||
"maintainer": "YamazakuraH",
|
||||
"maintainer_link": "https://github.com/YamazakuraH",
|
||||
"kernel_name": "kernel_xiaomi_cepheus",
|
||||
"kernel_link": "https://github.com/169163-Network/kernel_xiaomi_cepheus",
|
||||
"devices": "cepheus for pixel experience"
|
||||
},
|
||||
{
|
||||
"maintainer": "SakuraNotStupid",
|
||||
"maintainer_link": "https://github.com/SakuraNotStupid",
|
||||
"kernel_name": "android_kernel_xiaomi_sdm710",
|
||||
"kernel_link": "https://github.com/SakuraNotStupid/android_kernel_xiaomi_sdm710",
|
||||
"devices": "MI8SE(sirius) for LineageOS"
|
||||
},
|
||||
{
|
||||
"maintainer": "Aquarius223(paper)",
|
||||
"maintainer_link": "https://github.com/Aquarius223",
|
||||
"kernel_name": "android_kernel_xiaomi_msm8998",
|
||||
"kernel_link": "https://github.com/sticpaper/android_kernel_xiaomi_msm8998-ksu",
|
||||
"devices": "MI 6 (sagit) and MIX 2 (chiron) for LineageOS"
|
||||
},
|
||||
{
|
||||
"maintainer": "SlackerState",
|
||||
"maintainer_link": "https://github.com/SlackerState",
|
||||
"kernel_name": "android_kernel_xiaomi_sm6150",
|
||||
"kernel_link": "https://github.com/SlackerState/android_kernel_xiaomi_sm6150",
|
||||
"devices": "Redmi K30 4G (phoenix)"
|
||||
},
|
||||
{
|
||||
"maintainer": "RooGhz720",
|
||||
"maintainer_link": "https://github.com/RooGhz720",
|
||||
"kernel_name": "Aghisna_Sweet_Kernel",
|
||||
"kernel_link": "https://github.com/RooGhz720/Aghisna_Sweet_Kernel",
|
||||
"devices": "REDMI NOTE 10 PRO (sweet)"
|
||||
},
|
||||
{
|
||||
"maintainer": "OnlyTomInSecond",
|
||||
"maintainer_link": "https://github.com/onlyTomInSecond/",
|
||||
"kernel_name": "android_kernel_xiaomi_sdm845",
|
||||
"kernel_link": "https://github.com/OnlyTomInSecond/android_kernel_xiaomi_sdm845",
|
||||
"device": "Mi 8 (dipper) for LOS"
|
||||
}
|
||||
]
|
||||
@@ -11,7 +11,7 @@ Trang này chỉ để cho bạn tìm thấy source cho thiết bị của bạn
|
||||
:::
|
||||
|
||||
<script setup>
|
||||
import data from '../../repos'
|
||||
import data from '../../repos.json'
|
||||
</script>
|
||||
|
||||
<table>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
:::
|
||||
|
||||
<script setup>
|
||||
import data from '../../repos'
|
||||
import data from '../../repos.json'
|
||||
</script>
|
||||
|
||||
<table>
|
||||
|
||||
Reference in New Issue
Block a user