Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet <98699436+gitclone-url@users.noreply.github.com>
  • Loading branch information
gitclone-url committed May 24, 2024
0 parents commit 95d1348
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
145 changes: 145 additions & 0 deletions .github/workflows/Recovery Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Recovery Build

on:
workflow_dispatch:
inputs:
MANIFEST_URL:
description: 'MANIFEST_URL (if want to use SSH keys, use git@github.com:XXXXX)'
required: true
default: 'PLACEHOLDER'
MANIFEST_BRANCH:
description: 'MANIFEST_BRANCH'
required: true
default: 'PLACEHOLDER'
DEVICE_TREE_URL:
description: 'DEVICE_TREE_URL'
required: true
default: 'PLACEHOLDER'
DEVICE_TREE_BRANCH:
description: 'DEVICE_TREE_BRANCH'
required: true
default: 'PLACEHOLDER'
DEVICE_PATH:
description: 'DEVICE_PATH'
required: true
default: 'PLACEHOLDER'
DEVICE_NAME:
description: 'DEVICE_NAME'
required: true
default: 'PLACEHOLDER'
MAKEFILE_NAME:
description: 'MAKEFILE_NAME'
required: true
default: 'PLACEHOLDER'
BUILD_TARGET:
description: 'BUILD_TARGET'
required: true
default: 'PLACEHOLDER'
USER_NAME:
description: 'Git Username'
required: true
default: 'PLACEHOLDER'
USER_EMAIL:
description: 'Git Email'
required: true
default: 'PLACEHOLDER'

jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Display Run Parameters
run: |
echo "::group::User Environment Variables"
echo "Manifest URL: ${{ github.event.inputs.MANIFEST_URL }}"
echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}"
echo "Device Tree URL: ${{ github.event.inputs.DEVICE_TREE_URL }}"
echo "Device Tree Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}"
echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}"
echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}"
echo "Makefile Name: ${{ github.event.inputs.MAKEFILE_NAME }}"
echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}.img"
echo "::endgroup::"
- name: Check Out
uses: actions/checkout@v4

- name: Cleanup
uses: rokibhasansagar/slimhub_actions@main

- name: Prepare the environment
run: |
sudo apt install git aria2 -y
mkdir ofx_scripts
cd ofx_scripts
git clone https://gitlab.com/OrangeFox/misc/scripts
cd scripts
sudo bash setup/android_build_env.sh
sed -i 's/cd -/cd ../g' setup/install_android_sdk.sh
sudo bash setup/install_android_sdk.sh
- name: Setup SSH Keys
if: ${{ startsWith(github.event.inputs.MANIFEST_URL, 'git@github.com') }}
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: |
${{ secrets.SSH_PRIVATE_KEY }}
- name: Install repo
run: |
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
sudo ln -sf ~/bin/repo /usr/bin/repo
- name: Initialize repo
run: |
mkdir workspace
cd workspace
echo "workspace-folder=$(pwd)" >> $GITHUB_OUTPUT
git config --global user.name "${{ github.event.inputs.USER_NAME }}"
git config --global user.email "${{ github.event.inputs.USER_EMAIL }}"
repo init --depth=1 -u ${{ github.event.inputs.MANIFEST_URL }} -b ${{ github.event.inputs.MANIFEST_BRANCH }}
id: pwd

- name: Repo Sync
run: |
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j$(nproc --all)
working-directory: workspace

- name: Clone device tree
run: |
git clone ${{ github.event.inputs.DEVICE_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }}
working-directory: ${{ steps.pwd.outputs.workspace-folder }}

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Building recovery
run: |
source build/envsetup.sh
export ALLOW_MISSING_DEPENDENCIES=true
lunch ${{ github.event.inputs.MAKEFILE_NAME }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all)
working-directory: ${{ steps.pwd.outputs.workspace-folder }}

- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
files: |
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/*.zip
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/*vendor*.img
name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }}
tag_name: ${{ github.run_id }}
body: |
Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }}
Device: ${{ github.event.inputs.DEVICE_NAME }}
Target: ${{ github.event.inputs.BUILD_TARGET }}.img
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

128 changes: 128 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Use Github Action to compile Recovery

- Support TWRP, SHRP compilation and production

---

## OrangeFox is [here](https://github.com/azwhikaru/Action-OFRP-Builder)

---

## I can't help you with Device Tree problems! Issues that do not indicate script errors will be closed!

---

## Thanks to
- All contributors

---

## Release Notes
```
= 2022/10/28
- OFRP manifest is changed, so not fully support OFRP now (if you can slove this, please submit a pull request!)
= 2022/07/08
- TWRP and TWRP-based 5.X ~ 12.X are ***ALL COMPILED SUCCESSFULLY***
= 2022/07/06
- Add support for 5.1 branch
= 2022/07/05
- Updated to work with trees back to 6.0
- Add conditionals to include common trees for syncing
- Update README for SSH keys
= 2022/07/04
- Updated to work with Android 12.1 AOSP minimal TWRP manifest
= 2022/05/29
- Should work correctly with Android 11 based source code
= 2022/02/03
- Due to the hardware resource limitation of GitHub action, this version cannot be compiled based on AOSP and other source codes of Android 11 and above. If necessary, please use local compilation
= 2021/10/29:
- Refactored version 2.0
- Completely reconstruct the use logic to reduce the difficulty of use
- Optimize the parameter transfer part, now you can run multiple Workers at the same time
```

-----

## Parameter Description

| Name | Description | Example |
| ------------ | -------------------- | ------------ |
| `MANIFEST_URL` | Source address | https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git |
| `MANIFEST_BRANCH` | Source branch | twrp-12.1 |
| `DEVICE_TREE_URL` | Device address | https://github.com/TeamWin/android_device_asus_I003D |
| `DEVICE_TREE_BRANCH` | Device branch | android-12.1 |
| `DEVICE_PATH` | Device location | device/asus/I003D |
| `COMMON_TREE_URL` | Common tree address | https://github.com/TeamWin/android_device_asus_sm8250-common |
| `COMMON_PATH` | Common tree location | device/asus/sm8250-common |
| `DEVICE_NAME` | Model name | I003D |
| `MAKEFILE_NAME` | Makefile name | twrp_I003D |
| `BUILD_TARGET` | Build Target Partition (boot/recovery/vendorboot) | recovery |

-----

## How to use
```
For example, your username is: JohnSmith
```
#### 1. Click 'Fork' in the upper right corner of this repository
![image](https://user-images.githubusercontent.com/37921907/177914706-c92476c5-7e14-4fb3-be94-0c8a11dae874.png)
#### 2. After waiting for the automatic redirection, you will see your own username
![image](https://user-images.githubusercontent.com/37921907/177915106-5bde6fc9-303c-479e-b290-22b48efd1e4e.png)
#### 3. Change the [username and email](https://github.com/CaptainThrowback/Action-Recovery-Builder/blob/main/.github/workflows/Recovery%20Build.yml#L100-L101) in the workflow to reflect your Github credentials (optional)
## Setting up SSH Keys (optional)
#### 4. Go to Settings, then select Deploy keys and select "Add deploy key" button.

#### 5. On your Android device, install [Termux](https://github.com/termux/termux-app/releases)

#### 6. Install openssh in Termux and generate ssh keys. (Do not use passphrase for keys)
NOTE: When creating the deploy key for a repository like git@github.com:owner/repo.git or https://github.com/owner/repo, put that URL into the key comment. (Hint: Try ssh-keygen ... -C "git@github.com:owner/repo.git".)
owner = your Github username
```
pkg install openssh
ssh-keygen -t ed25519 -C "git@github.com:owner/Action-Recovery-Builder.git"
```
#### 7. Add the keys to your repo. In Termux, use the following commands:
```
cd /data/data/com.termux/files/usr/etc/ssh
cat ssh_host_ed25519_key.pub
```
Select and copy the key then paste in the box for Key.
You can name it whatever you choose for the title.

#### 8. Now to add your private ssh key. Back in Termux:
```
cat ssh_host_ed25519_key
```
Copy the output from Termux.

In your browser, select *Secrets* under the Security tab.
Select Actions
Select New repository secret
For the New secret name, it should be SSH_PRIVATE_KEY
Paste the output from ssh_host_ed25519_key into the Value box.
Then select Add secret.

## Building the Recovery
#### 9. Click 'Actions-Recovery Build'
![image](https://user-images.githubusercontent.com/37921907/177915304-8731ed80-1d49-48c9-9848-70d0ac8f2720.png)
#### 10. Click 'Run workflow' and fill in according to the above 'parameter description'
![image](https://user-images.githubusercontent.com/37921907/177915346-71c29149-78fb-4a00-996f-5d84ffc9eb8c.png)
#### 11. After filling in, click 'Run workflow' to start running

-----

## Compilation results
Can be downloaded at [Release](../../releases)

-----
## Remark

#### TeamWin Recovery Project: https://github.com/minimal-manifest-twrp
#### SKYHAWK Recovery Project: https://github.com/SHRP/manifest

0 comments on commit 95d1348

Please sign in to comment.