Skip to content

112

112 #336

Workflow file for this run

name: PR - Build Changed Projects
run-name: >
${{
github.event_name == 'workflow_dispatch' && github.event.inputs.pr_number ||
github.event_name == 'repository_dispatch' && github.event.client_payload.pr_number ||
''
}}
permissions:
id-token: write
contents: read
pull-requests: write
on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR Number'
required: true
pull_request_target:
types: [synchronize]
repository_dispatch:
types: [pr_build]
jobs:
build:
runs-on: windows-2025
steps:
- name: Ensure recent manual trigger
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
if ("${{ github.event_name }}" -eq "pull_request_target") {
$ONE_MONTH_AGO = (Get-Date).AddMonths(-1).ToString("yyyy-MM-dd")
$RUN_NAMES = gh api "repos/${{ github.repository }}/actions/workflows/pr_build.yml/runs?event=workflow_dispatch&created=>=$ONE_MONTH_AGO" --jq '.workflow_runs[].display_title'
if ($RUN_NAMES -notcontains "${{ github.event.pull_request.number }}") {
Write-Host "Run this workflow manually - it hasn't been done recently"
exit 1
}
}
- name: Install Pipeline Package
shell: pwsh
run: |
git clone https://x-token-auth:${{ secrets.STARTER_PROJECTS_PIPELINE_TOKEN }}@bitbucket.org/imagimob/starter-projects-pipeline.git
pip install -e starter-projects-pipeline
- name: Build changed projects
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SENSOR_MAP: ${{ vars.SENSOR_MAP }}
STARTER_PROJECTS_PIPELINE_TOKEN: ${{ secrets.STARTER_PROJECTS_PIPELINE_TOKEN }}
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
dcp update-changes --pr-number ${{ github.event.inputs.pr_number }}
} elseif ("${{ github.event_name }}" -eq "pull_request_target") {
dcp update-changes --pr-number ${{ github.event.pull_request.number }}
} elseif ("${{ github.event_name }}" -eq "repository_dispatch") {
dcp update-trained --project '${{ toJson(github.event.client_payload) }}'
} else {
throw "Unsupported event: ${{ github.event_name }}"
}