Skip to content

Update application source code from nRF Connect SDK #2

Update application source code from nRF Connect SDK

Update application source code from nRF Connect SDK #2

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@v4
- 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@v4
- 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 "[email protected]"
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