Skip to content

Raspberry Pi Ansible Script #68

Raspberry Pi Ansible Script

Raspberry Pi Ansible Script #68

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: build-modified-projects
runs-on: ubuntu-latest
environment: deploy
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.setup.outputs.matrix_all_projects) }}
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@v2
with:
name: build-Demo-Blink-cli-31324e8
- name: Deploy to Raspberry Pi
run: |
scp -r build-Demo-Blink-cli-31324e8 [email protected]:
- name: Verify deployment
run: |
ssh [email protected]
ls build-Demo-Blink-cli-31324e8