From 06be23b80191999c147429b34d2a89304d2c4642 Mon Sep 17 00:00:00 2001 From: hayzam Date: Thu, 7 Mar 2024 12:40:56 +0530 Subject: [PATCH] actions: add dmsbg-100 workflow, ignore: .secrets --- .forgejo/workflows/dmsbg-100.yml | 72 ++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 73 insertions(+) create mode 100644 .forgejo/workflows/dmsbg-100.yml diff --git a/.forgejo/workflows/dmsbg-100.yml b/.forgejo/workflows/dmsbg-100.yml new file mode 100644 index 0000000000..b23f1f99b4 --- /dev/null +++ b/.forgejo/workflows/dmsbg-100.yml @@ -0,0 +1,72 @@ +on: + push: + tags: + - 'v*.*.*' + +env: + GIT_PAT: ${{ secrets.GIT_PAT }} + PORTAL_ENDPOINT: ${{ secrets.PORTAL_ENDPOINT }} + PORTAL_API_KEY: ${{ secrets.PORTAL_API_KEY }} + +jobs: + build-and-publish: + runs-on: self-hosted + steps: + - name: Determine Environment + id: determine-env + run: | + TAG_REF=${GITHUB_REF#refs/tags/} + IFS='.' read -ra VERSION <<< "$TAG_REF" + if [[ ${VERSION[2]} -eq 0 ]]; then + echo "ENVIRONMENT=master" >> $GITHUB_ENV + echo "cache-prefix=master" >> $GITHUB_ENV + echo "::set-output name=cache-prefix::master" + else + echo "ENVIRONMENT=staging" >> $GITHUB_ENV + echo "cache-prefix=staging" >> $GITHUB_ENV + echo "::set-output name=cache-prefix::staging" + fi + + - name: Cache DifOS Build Directory + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-${{ steps.determine-env.outputs.cache-prefix }}-difos-${{ hashFiles('**/dmsbg100.config') }}-${{ github.sha }} + path: . + restore-keys: | + ${{ runner.os }}-${{ steps.determine-env.outputs.cache-prefix }}-difos-${{ hashFiles('**/dmsbg100.config') }} + ${{ runner.os }}-${{ steps.determine-env.outputs.cache-prefix }}-difos- + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Dependencies + run: | + apt-get update + apt-get install -y build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext libncurses-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget python3-setuptools swig + npm install -g pkg@5.8.1 + + - name: Add Custom Files + run: | + echo $GIT_PAT + git clone https://$GIT_PAT:x-oauth-basic@git.difuse.io/Difuse/difos-files.git + cd difos-files + ./setup-all.sh ${{ github.workspace }} $GIT_PAT + + - name: Build + run: | + ./scripts/feeds update -a + ./scripts/feeds install -a + cp -rf configs/dmsbg100.config .config + make defconfig + FORCE_UNSAFE_CONFIGURE=1 CONFIG_TARGET_ROOTFS_INITRAMFS=n make clean -j$(nproc) + FORCE_UNSAFE_CONFIGURE=1 CONFIG_TARGET_ROOTFS_INITRAMFS=n make download -j$(nproc) + FORCE_UNSAFE_CONFIGURE=1 CONFIG_TARGET_ROOTFS_INITRAMFS=n make world -j$(nproc) + + - name: Publish Release + run: | + difosDir='.' + cd $difosDir + sdFile=$(find ./bin/ -name "*difos*" | grep sdcard | head -n1) + sqFile=$(find ./bin/ -name "*difos*" | grep squash | head -n1) + curl -X POST -H 'Content-Type: multipart/form-data' -F "file=@$sdFile" http://$PORTAL_ENDPOINT/software/upload/sd/$ENVIRONMENT/${{ env.PORTAL_API_KEY }} + curl -X POST -H 'Content-Type: multipart/form-data' -F "file=@$sqFile" http://$PORTAL_ENDPOINT/software/upload/sysupgrade/$ENVIRONMENT/${{ env.PORTAL_API_KEY }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 84cfc99770..8c047011d3 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ git-src .cproject .ccache .vscode* +.secrets