Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Update application source code from nRF Connect SDK #1319

Update application source code from nRF Connect SDK

Update application source code from nRF Connect SDK #1319

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@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Get NCS version
id: version
run: echo "version=`node .github/ncs-version.js`" >> $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 --depth 1 --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@v3
with:
token: ${{ secrets.CI_GITHUB_TOKEN }}
event-type: source-update