This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
75 lines (71 loc) · 2.44 KB
/
update-from-ncs.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
name: Update application source code from nRF Connect SDK
on:
schedule:
- cron: "0 0 * * *"
push:
paths:
- ".github/workflows/update-from-ncs.yaml"
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
jobs:
ncs:
name: Determine NCS version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- uses: actions/cache@v3
name: Cache dependencies
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Get NCS version
id: version
run: echo "version=`node .github/ncs-version.mjs`" >> $GITHUB_OUTPUT
update:
runs-on: ubuntu-22.04
needs: [ncs]
steps:
- uses: actions/checkout@v3
- name: Remove upstream files
run: rm -rf ./{src,boards,child_image,tests,configuration,doc,include}
- name: Update from upstream
run: |
git clone --single-branch --branch ${{ needs.ncs.outputs.version }} https://github.com/nrfconnect/sdk-nrf sdk-nrf
cp -rv sdk-nrf/applications/asset_tracker_v2/* ./
echo "UPSTREAM_REV=`git -C sdk-nrf rev-parse HEAD | tr -d '\n'`" >> $GITHUB_ENV
rm -rf sdk-nrf
- name: Check if changes were made
run: |
if [[ `git status --porcelain` ]]; then
echo "HAS_CHANGES=1" >> $GITHUB_ENV
else
echo "HAS_CHANGES=0" >> $GITHUB_ENV
fi
- name: Commit update
if: env.HAS_CHANGES == '1'
run: |
echo "machine github.com login accesskey password ${GITHUB_TOKEN}" > ~/.netrc
git config --global user.email "actions@example.com"
git config --global user.name "github-actions[bot]"
git add -A
git commit -m "fix: update from upstream
See https://github.com/nrfconnect/sdk-nrf/tree/${{ env.UPSTREAM_REV }}/applications/asset_tracker_v2"
git pull --rebase
git push
- name: Trigger build
if: env.HAS_CHANGES == '1'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CI_GITHUB_TOKEN }}
event-type: source-update