-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (81 loc) · 3.18 KB
/
os-workflow.yml
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
name: OS workflow
on:
workflow_call:
inputs:
repository:
description: 'edi project repository'
required: true
type: string
default: 'edi-pi'
repository_version:
description: 'branch/version of edi project repository'
required: true
type: string
default: 'master'
configuration:
description: 'OS image configuration'
required: true
type: string
default: 'pi4-gitops.yml'
build_command:
description: 'edi build command'
required: true
type: string
default: 'sudo edi -v image create'
device_id:
description: 'Mender device ID'
required: true
type: string
runner_label:
description: 'label to select runner'
required: true
type: string
default: ARM64
run_tests:
description: 'Test new OS image'
required: true
type: boolean
default: true
jobs:
build-dispatch-test:
runs-on: [self-hosted, Linux, "${{ inputs.runner_label }}"]
steps:
- name: Print summary of job
run: echo "${{ inputs.repository }}/${{ inputs.repository_version }}:${{ inputs.configuration }} --> ${{ inputs.device_id }} (run_tests=${{ inputs.run_tests }})"
- name: Check out the source code of this repository
uses: actions/checkout@v4
- name: Check out the source code of the edi project repository
uses: actions/checkout@v4
with:
repository: '${{ github.repository_owner }}/${{ inputs.repository }}'
ref: '${{ inputs.repository_version }}'
path: '${{ inputs.repository }}'
submodules: recursive
- name: Apply the correct Mender tenant token
run: |
echo "mender_tenant_token: \"${MENDER_TENANT_TOKEN}\"" > ${{ inputs.repository }}/configuration/mender/mender_custom.yml
env:
MENDER_TENANT_TOKEN: ${{ secrets.MENDER_TENANT_TOKEN }}
- name: Add additional ssh public key for ci/cd remote administration
run: |
if [[ "${CI_CD_SSH_PUB_KEY}" != "" ]]
then
echo "${CI_CD_SSH_PUB_KEY}" > ${{ inputs.repository }}/ssh_pub_keys/ci-cd-admin.pub
fi
env:
CI_CD_SSH_PUB_KEY: ${{ secrets.CI_CD_SSH_PUB_KEY }}
- name: Create the OS artifact
run: cd ${{ inputs.repository }} && ${{ inputs.build_command }} ${{ inputs.configuration }}
- name: Dispatch the OS artifact to the device
run: ./mender-api dispatch ${{ inputs.device_id }} ${{ inputs.repository }}/artifacts/$(echo "${{ inputs.configuration }}" | sed 's/yml$/mender/g')
env:
MENDER_ACCESS_TOKEN: ${{ secrets.MENDER_ACCESS_TOKEN }}
- name: Run tests on the device
run: ./run-tests ${{ inputs.device_id }} ${{ inputs.repository }}
env:
MENDER_ACCESS_TOKEN: ${{ secrets.MENDER_ACCESS_TOKEN }}
DEVICE_SECRETS: ${{ secrets.DEVICE_SECRETS }}
if: inputs.run_tests
- name: Perform cleanup
run: cd ${{ inputs.repository }} && ${{ inputs.build_command }} --recursive-clean 10 ${{ inputs.configuration }} ; sudo rm -rf ${{ inputs.repository }}
if: always()