Extract img file #4
This file contains 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: Extract img file | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
type_file: | |
description: "Select type file" | |
required: false | |
default: "img.gz" | |
type: choice | |
options: | |
- img.xz | |
- img.gz | |
img_url: | |
description: "Set the url img file" | |
required: true | |
default: "" | |
rename_rootfs: | |
description: "Rename rootfs" | |
required: true | |
default: "" | |
env: | |
TZ: Asia/Jakarta | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -qq update | |
sudo -E apt-get -y install wget python3 | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo pip3 install gdown | |
sudo pip3 install git+https://github.com/Juvenal-Yescas/mediafire-dl | |
wget https://mega.nz/linux/repo/xUbuntu_20.04/amd64/megacmd-xUbuntu_20.04_amd64.deb && sudo apt install "$PWD/megacmd-xUbuntu_20.04_amd64.deb" | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /workdir/openwrt | |
sudo chown $USER:$GROUPS /workdir | |
- name: Download file ${{ github.event.inputs.type_file }} | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
if [ $(echo ${{ github.event.inputs.img_url }} | grep "drive.") ]; then | |
if [ $(echo ${{ github.event.inputs.img_url }} | awk -F "/" '{print $6}') ]; then | |
link_gdrive=$(echo ${{ github.event.inputs.img_url }} | awk -F "/" '{print $6}') | |
else | |
link_gdrive=$(echo ${{ github.event.inputs.img_url }} | awk -F "/" '{print $4}' | awk -F "?id=" '{print $2}'|awk -F "&export" '{print $1}') | |
fi | |
sudo gdown ${link_gdrive} -O openwrt/file.${{ github.event.inputs.type_file }} | |
else | |
if [ $(echo ${{ github.event.inputs.img_url }} | grep "mediafire.com") ]; then | |
sudo mediafire-dl ${{ github.event.inputs.img_url }} -o openwrt/file.${{ github.event.inputs.type_file }} | |
else | |
if [ $(echo ${{ github.event.inputs.img_url }} | grep "mega.nz") ]; then | |
file_mega=$(sudo mega-get ${{ github.event.inputs.img_url }} | awk -F: '{print $2}') | |
sudo mv ${file_mega} openwrt/file.${{ github.event.inputs.type_file }} | |
else | |
sudo wget --no-check-certificate ${{ github.event.inputs.img_url }} -O openwrt/file.${{ github.event.inputs.type_file }} | |
fi | |
fi | |
fi | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: Extract firmware | |
id: extract | |
run: | | |
cd openwrt | |
sudo mkdir -p boot rootfs img | |
if [ ${{ github.event.inputs.type_file }} = "img.gz" ]; then | |
sudo gunzip file.img.gz | |
else | |
sudo unxz file.img.xz | |
fi | |
los=$(sudo losetup -fP --show file.img) | |
sudo mount ${los}p2 rootfs | |
(cd rootfs && sudo tar cfz /workdir/openwrt/img/${{ inputs.rename_rootfs }}.tar.gz *) | |
echo "::set-output name=status::success" | |
- name: Check space usage | |
if: (!cancelled()) | |
run: df -hT | |
- name: Upload release asset | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: openwrt/img/* | |
tag: ${{ github.ref }} | |
file_glob: true | |
overwrite: true | |
body: | | |
## KUMPULAN HASIL MALINK ROOTFS | |
- name: Delete workflow runs | |
uses: GitRML/delete-workflow-runs@main | |
with: | |
retain_days: 1 | |
keep_minimum_runs: 3 |