Add workflow cache

This commit is contained in:
viktorxda
2024-03-26 07:55:03 +01:00
committed by Viktor
parent 11b309932d
commit f244dfe16d

View File

@@ -6,9 +6,6 @@ on:
env: env:
TAG_NAME: latest 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: jobs:
buildroot: buildroot:
@@ -68,19 +65,32 @@ jobs:
- name: Prepare firmware - name: Prepare firmware
run: | run: |
echo "8.8.8.8 invisible-mirror.net" | sudo tee -a /etc/hosts echo CACHE_DATE=$(date +%m) >> ${GITHUB_ENV}
echo "8.8.8.8 distfiles.dereferenced.org" | sudo tee -a /etc/hosts
git clone https://github.com/openipc/firmware --depth 1 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 - name: Build firmware
run: | run: |
export GIT_HASH=$(git rev-parse --short ${GITHUB_SHA}) export GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
export GIT_BRANCH=${GITHUB_REF_NAME} 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}} NAME=${{matrix.platform}}
bash builder.sh ${NAME} bash builder.sh ${NAME}
cd openipc cd openipc
TIME=$(date -d @${SECONDS} +%M:%S)
echo TIME=${TIME} >> ${GITHUB_ENV}
NORFW=$(find output/images -name openipc*nor*) NORFW=$(find output/images -name openipc*nor*)
if [ ! -z ${NORFW} ]; then if [ ! -z ${NORFW} ]; then
mv ${NORFW} ../${NAME}-nor.tgz 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_MSG="Commit: ${GIT_HASH}\nBranch: ${GIT_BRANCH}\nTag: ${TAG_NAME}\nTime: ${TIME}\n\n"
TG_ICON="\xE2\x9C\x85 GitHub Actions" TG_ICON="\xE2\x9C\x85 GitHub Actions"
TG_HEADER=$(echo -e ${TG_MSG}${TG_ICON}) 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} echo Telegram response: ${HTTP}