-
Notifications
You must be signed in to change notification settings - Fork 3
100 lines (86 loc) · 2.81 KB
/
test-self-hosted.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Test Self-Hosted Runner
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
jobs:
setup:
runs-on: self-hosted
outputs:
matrix_all_projects: ${{ steps.projects.outputs.matrix_all_projects }}
matrix_modified_projects: ${{ steps.projects.outputs.matrix_modified_projects }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
run: |
python3 -m venv .venv
- name: Get projects
id: projects
run: |
source .venv/bin/activate
BASE_REF="${{ github.base_ref }}" # Target branch of the PR
BASE_REF="${BASE_REF:-HEAD^}" # Previous commit on push to main
python3 .github/scripts/get_projects_matrix.py origin/$BASE_REF
echo "matrix_all_projects=$(cat all_projects_matrix.json)" >> $GITHUB_OUTPUT
echo "matrix_modified_projects=$(cat modified_projects_matrix.json)" >> $GITHUB_OUTPUT
build-all-projects:
if: false
needs: setup
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.setup.outputs.matrix_all_projects) }}
uses: ./.github/workflows/reusable-build-project.yml
with:
project: ${{ matrix.project }}
platform: ${{ matrix.platform }}
build-modified-projects:
needs: setup
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.setup.outputs.matrix_modified_projects) }}
uses: ./.github/workflows/reusable-build-project.yml
with:
project: ${{ matrix.project }}
platform: ${{ matrix.platform }}
deploy-modified-projects:
needs: [setup, build-modified-projects]
runs-on: ubuntu-latest
environment: deploy
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.setup.outputs.matrix_modified_projects) }}
outputs:
artifact_name: ${{ steps.build.outputs.artifact_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install tailscale
run: |
curl -fsSL https://tailscale.com/install.sh | sh
- name: Add machine to tailscale network
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }}
tags: tag:ci
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-modified-projects.outputs.artifact_name }}
- name: Deploy to Raspberry Pi
run: |
scp -r ${{ needs.build-modified-projects.outputs.artifact_name }} [email protected]:
- name: Verify deployment
run: |
ls build-Demo-Blink-cli-31324e8