From f244dfe16d653ec1e06229c08904d98bfa92634a Mon Sep 17 00:00:00 2001 From: viktorxda <35473052+viktorxda@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:55:03 +0100 Subject: [PATCH] Add workflow cache --- .github/workflows/master.yml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a4d9c9b..49279d5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -1,14 +1,11 @@ name: Build on: schedule: - - cron: '0 3 * * *' + - cron: '0 3 * * *' workflow_dispatch: env: TAG_NAME: latest - TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}} - TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}} - TG_OPTIONS: -s -o /dev/null -w %{http_code} jobs: buildroot: @@ -68,19 +65,32 @@ jobs: - name: Prepare firmware run: | - echo "8.8.8.8 invisible-mirror.net" | sudo tee -a /etc/hosts - echo "8.8.8.8 distfiles.dereferenced.org" | sudo tee -a /etc/hosts + echo CACHE_DATE=$(date +%m) >> ${GITHUB_ENV} git clone https://github.com/openipc/firmware --depth 1 + - name: Setup ccache + uses: actions/cache@v4 + with: + path: /tmp/ccache + key: ${{matrix.platform}}-${{env.CACHE_DATE}} + - name: Build firmware run: | export GIT_HASH=$(git rev-parse --short ${GITHUB_SHA}) export GIT_BRANCH=${GITHUB_REF_NAME} + echo GIT_HASH=${GIT_HASH} >> ${GITHUB_ENV} + echo GIT_BRANCH=${GIT_BRANCH} >> ${GITHUB_ENV} + + mkdir -p /tmp/ccache + ln -s /tmp/ccache ${HOME}/.ccache NAME=${{matrix.platform}} bash builder.sh ${NAME} cd openipc + TIME=$(date -d @${SECONDS} +%M:%S) + echo TIME=${TIME} >> ${GITHUB_ENV} + NORFW=$(find output/images -name openipc*nor*) if [ ! -z ${NORFW} ]; then mv ${NORFW} ../${NAME}-nor.tgz @@ -106,5 +116,7 @@ jobs: TG_MSG="Commit: ${GIT_HASH}\nBranch: ${GIT_BRANCH}\nTag: ${TAG_NAME}\nTime: ${TIME}\n\n" TG_ICON="\xE2\x9C\x85 GitHub Actions" TG_HEADER=$(echo -e ${TG_MSG}${TG_ICON}) - HTTP=$(curl ${TG_OPTIONS} -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot${TG_TOKEN}/sendDocument -F chat_id=${TG_CHANNEL} -F caption="${TG_HEADER}" -F document=@${NORFW}) + TG_TOKEN=${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}} + TG_CHANNEL=${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}} + HTTP=$(curl -s -o /dev/null -w %{http_code} https://api.telegram.org/bot${TG_TOKEN}/sendDocument -F chat_id=${TG_CHANNEL} -F caption="${TG_HEADER}" -F document=@${NORFW}) echo Telegram response: ${HTTP}