Ares-Device-Tree-Generator #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Ares-Device-Tree-Generator | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| DEVICE_IMG: | |
| description: '(.img) file link' | |
| required: true | |
| default: 'https://github.com/abrohim0786/OrangeFox-Recovery-Builder-2025/releases/download/16670367505/boot.img' | |
| DEVICE_BRANCH: | |
| description: 'your device branch name (Optional)' | |
| required: true | |
| default: 'android-12.1' | |
| EMPTY_REPO: | |
| description: 'your empty repo name on github (Optional)' | |
| required: true | |
| default: 'android_device_xiaomi_ares' | |
| COMMIT_MESSAGE: | |
| description: 'your commit message (Optional)' | |
| required: true | |
| default: 'TWRP device tree Xiaomi Redmi K40 Gaming Poco F3GT' | |
| PUSH_GITHUB: | |
| description: 'Push to GitHub Repository.' | |
| type: boolean | |
| required: true | |
| default: false | |
| RELEASE_FILE: | |
| description: 'Upload file to GitHub Release too.' | |
| type: boolean | |
| required: true | |
| default: true | |
| jobs: | |
| build: | |
| name: Device Tree Generator by ${{ github.actor }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Getting tools ready | |
| run: | | |
| pip3 install twrpdtgen | |
| sudo apt-get install cpio zip | |
| - name: Downloading .img file | |
| run: | | |
| wget ${{ github.event.inputs.DEVICE_IMG }} | |
| if [ -f ./recovery.img ]; then | |
| echo "RECOVERY_TYPE=recovery" >> $GITHUB_ENV | |
| elif [ -f ./boot.img ]; then | |
| echo "RECOVERY_TYPE=boot" >> $GITHUB_ENV | |
| elif [ -f ./vendor_boot.img ]; then | |
| echo "RECOVERY_TYPE=vendor_boot" >> $GITHUB_ENV | |
| else | |
| echo "No Recovery file found!" | |
| exit 1 | |
| fi | |
| - name: Generating Device tree | |
| run: | | |
| python3 -m twrpdtgen ./${{ env.RECOVERY_TYPE }}.img | |
| - name: Set Build Date | |
| run: | | |
| echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV | |
| - name: getting device information | |
| run: | | |
| mv ./output/ device | |
| DEVICE_PATH=$(find device -type f \( -name "Android.mk" -o -name "BoardConfig.mk" \) | head -n 1) | |
| if [ -z "$DEVICE_PATH" ]; then | |
| DEVICE_DIR=$(find device -type d | sort | tail -n 1) | |
| else | |
| DEVICE_DIR=$(dirname "$DEVICE_PATH") | |
| fi | |
| echo "DEVICE_DIR=$DEVICE_DIR" >> $GITHUB_ENV | |
| DEVICE_ID=$(basename "$(dirname "$DEVICE_DIR")") | |
| DEVICE_IDD=$(basename "$DEVICE_DIR") | |
| echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV | |
| echo "DEVICE_IDD=$DEVICE_IDD" >> $GITHUB_ENV | |
| - name: Add to Zip | |
| run: | | |
| zip -r ${{ env.DEVICE_ID }}_${{ env.DEVICE_IDD }}_tree.zip ./device/ | |
| - name: Release | |
| if: github.event.inputs.RELEASE_FILE == 'true' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: ${{ env.DEVICE_ID }}_${{ env.DEVICE_IDD }}_tree.zip | |
| name: ${{ env.DEVICE_ID }} ${{ env.DEVICE_IDD }} device tree // ${{ env.BUILD_DATE }} | |
| tag_name: ${{ github.run_id }} | |
| body: Automated device tree release for ${{ env.DEVICE_ID }} ${{ env.DEVICE_IDD }} on ${{ env.BUILD_DATE }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push to GitHub | |
| if: github.event.inputs.PUSH_GITHUB == 'true' | |
| run: | | |
| git config --global user.email "abrohim0786" | |
| git config --global user.name "callofduty.pubg786@gmail.com" | |
| cd "$DEVICE_DIR" || exit 1 | |
| git init | |
| git add . | |
| git commit -m "${{ github.event.inputs.COMMIT_MESSAGE }}" | |
| git branch -M ${{ github.event.inputs.DEVICE_BRANCH }} | |
| git remote add origin https://abrohim0786:${{ secrets.GITHUB_TOKEN }}@github.com/abrohim0786/${{ github.event.inputs.EMPTY_REPO }}.git | |
| git push -u origin ${{ github.event.inputs.DEVICE_BRANCH }} |