-
Notifications
You must be signed in to change notification settings - Fork 74
187 lines (164 loc) · 6.3 KB
/
build-cache-1.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: build-cache
on:
schedule:
# 22:30 PST / Sunday
- cron: '30 06 * * 1'
workflow_dispatch:
inputs:
tg_disabled:
type: boolean
description: 'Disable Telegram notifications'
required: false
default: false
tg_scratch:
type: boolean
description: 'Use TG scratch channel'
required: false
default: false
env:
BR2_DL_DIR: ~/dl
FORCE_UNSAFE_CONFIGURE: 1
TAG_NAME: update_cache
TERM: linux
TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_THINGINO}}
TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_THINGINO_MULTI}}
TG_TOPIC: ${{secrets.TELEGRAM_CHANNEL_THINGINO_MULTI_TOPIC_FIRMWARE}}
TG_CHANNEL_SCRATCH: ${{secrets.TELEGRAM_CHANNEL_THINGINO_SCRATCH}}
TZ: America/Los_Angeles
jobs:
notify-begin:
runs-on: ubuntu-24.04
outputs:
start_time: ${{ steps.set_output.outputs.time }}
tg_disabled: ${{ steps.set_env.outputs.tg_disabled }}
steps:
- name: Set timezone
run: |
sudo timedatectl set-timezone ${{ env.TZ }}
- name: Save workflow start time to ENV
id: set_output
run: echo "time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Configure Environment Variables
run: |
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
echo "tg_disabled=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: "master"
fetch-depth: "1"
- name: Send build start notifcation via Telegram
if: env.TG_DISABLED == 'false'
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC start ${{ github.workflow }} ${{ github.run_id }} ${{ github.repository }}
build-caches:
name: ${{ matrix.caches-version }}
needs: notify-begin
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
container:
image: debian:bookworm
strategy:
fail-fast: false
matrix:
caches-version:
- build_cache
steps:
- name: Update package manager sources
run: |
apt-get update
- name: Install build dependencies
run: |
apt-get install -y --no-install-recommends --no-install-suggests build-essential bc ccache cmake cpio curl ca-certificates file git make gawk procps rsync u-boot-tools unzip wget
- name: Set timezone
run: |
ln -sf /usr/share/zoneinfo/${{ env.TZ }} /etc/localtime
echo ${{ env.TZ }} > /etc/timezone
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -f noninteractive tzdata
- name: Setup gh workspace to container
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout repository source
uses: actions/checkout@v4
with:
submodules: 'true'
ref: "master"
fetch-depth: "1"
- name: Configure environment variables
id: env
run: |
echo "WEEK_NUMBER=$(date +%U)" >> $GITHUB_ENV
echo "CURRENT_YEAR=$(date +%Y)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
TAG_NAME="$TAG_NAME-$(date +'%Y-%m-%d')"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_OUTPUT
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
- name: Setup cache directories
run: |
mkdir -p ~/.ccache
mkdir -p ~/dl
- name: Restore Buildroot DL cache
uses: actions/cache/restore@v4
if: always()
with:
path: ~/dl
key: ${{ runner.os }}-dl-shared-v1-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }}
restore-keys: |
${{ runner.os }}-ccache-shared-v1-${{ env.CURRENT_YEAR }}-
${{ runner.os }}-ccache-shared-v1-
- name: Generate buildroot cache
run: |
BOARD=${{ matrix.caches-version }} make fast
- name: Save Buildroot ccache
uses: actions/cache/save@v4
if: always()
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-shared-v1-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }}
- name: Send error notification
if: ${{ env.TG_DISABLED == 'false' && failure() }}
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC error $TAG_NAME ${{ github.run_id }} buildroot-cache-1 ${{ github.repository }}
notify-completion:
needs: [build-caches, notify-begin]
runs-on: ubuntu-24.04
if: always()
steps:
- name: Set timezone
run: |
sudo timedatectl set-timezone ${{ env.TZ }}
- name: Configure Environment
run: |
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
echo "GIT_HASH=${{ needs.build-caches.outputs.git_hash }}" >> $GITHUB_ENV
echo "TAG_NAME=${{ needs.build-caches.outputs.tag_name }}" >> $GITHUB_ENV
- name: Checkout repository source
uses: actions/checkout@v4
with:
submodules: 'false'
ref: "master"
- name: Send notify completion summary
if: ${{ env.TG_DISABLED == 'false' }}
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
START_TIME=${{ needs.notify-begin.outputs.start_time }}
END_TIME=$(date -u +%s)
ELAPSED=$((END_TIME - START_TIME))
ELAPSED_MIN=$((ELAPSED / 60))
ELAPSED_SEC=$((ELAPSED % 60))
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC finish ${{ github.workflow }} "${ELAPSED_MIN}m ${ELAPSED_SEC}s" ${{ github.run_id }} ${{ github.repository }}