123 lines
4.2 KiB
YAML
123 lines
4.2 KiB
YAML
name: Services Validation
|
|
description: Checks services configuration file and checks for defunct services
|
|
inputs:
|
|
repositorySecret:
|
|
description: GitHub token for API access
|
|
required: true
|
|
checkApiSecret:
|
|
description: Token for server check API
|
|
required: false
|
|
checkApiServers:
|
|
description: Servers for the check API
|
|
required: false
|
|
runSchemaChecks:
|
|
description: Enable schema checking
|
|
required: false
|
|
default: 'true'
|
|
runServiceChecks:
|
|
description: Enable defunct service checking
|
|
required: false
|
|
default: 'false'
|
|
createPullRequest:
|
|
description: Enable pull request creation after service checks
|
|
required: false
|
|
default: 'false'
|
|
workingDirectory:
|
|
description: Working directory for checks
|
|
required: false
|
|
default: ${{ github.workspace }}
|
|
outputs:
|
|
hasDefunctServices:
|
|
description: True if defunct services were found in configuration
|
|
value: ${{ steps.check.outputs.make_pr }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Check Runner Operating System 🏃♂️
|
|
if: runner.os == 'Windows'
|
|
shell: bash
|
|
run: |
|
|
: Check Runner Operating System 🏃♂️
|
|
echo "::notice::services-validation action requires a macOS-based or Linux-based runner."
|
|
exit 2
|
|
|
|
- name: Install and Configure Python 🐍
|
|
shell: bash
|
|
run: |
|
|
: Configure Python 🐍
|
|
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
|
|
|
|
python3 -m venv .venv
|
|
|
|
source .venv/bin/activate
|
|
python3 -m pip install jsonschema json_source_map requests aiohttp
|
|
echo ::endgroup::
|
|
|
|
- name: Validate Services File JSON Schema 🕵️
|
|
if: fromJSON(inputs.runSchemaChecks)
|
|
shell: bash
|
|
working-directory: ${{ inputs.workingDirectory }}
|
|
run: |
|
|
: Validate Services File JSON Schema 🕵️
|
|
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
|
|
shopt -s extglob
|
|
|
|
echo ::group::Run Validation
|
|
|
|
source .venv/bin/activate
|
|
python3 -u \
|
|
.github/scripts/utils.py/check-jsonschema.py \
|
|
plugins/rtmp-services/data/@(services|package).json \
|
|
--loglevel INFO
|
|
echo ::endgroup::
|
|
|
|
- name: Annotate schema validation errors 🏷️
|
|
if: fromJSON(inputs.runSchemaChecks) && failure()
|
|
uses: yuzutech/annotations-action@00b2d488bcba3bd01014dc073d276ef4a45d5c6c # v0.6.0
|
|
with:
|
|
repo-token: ${{ inputs.repositorySecret }}
|
|
title: Service JSON Errors
|
|
input: ${{ inputs.workingDirectory }}/validation_errors.json
|
|
|
|
- name: Restore Timestamp Cache ⏳
|
|
if: fromJSON(inputs.runServiceChecks)
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ${{ github.workspace }}/other
|
|
key: service-check-${{ github.run_id }}
|
|
restore-keys: service-check-
|
|
|
|
- name: Check for defunct services 📉
|
|
id: services-check
|
|
if: fromJSON(inputs.runServiceChecks)
|
|
shell: bash
|
|
working-directory: ${{ inputs.workingDirectory }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ inputs.repositorySecret }}
|
|
WORKFLOW_RUN_ID: ${{ github.run_id }}
|
|
REPOSITORY: ${{ github.repository }}
|
|
API_KEY: ${{ inputs.checkApiSecret }}
|
|
API_SERVERS: ${{ inputs.checkApiServers }}
|
|
run: |
|
|
: Check for defunct services 📉
|
|
|
|
source .venv/bin/activate
|
|
python3 -u .github/scripts/utils.py/check-services.py
|
|
|
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
if: fromJSON(inputs.runServiceChecks)
|
|
with:
|
|
name: timestamps
|
|
path: ${{ inputs.workingDirectory }}/other/*
|
|
|
|
- name: Create pull request 🔧
|
|
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
|
if: fromJSON(inputs.createPullRequest) && fromJSON(inputs.runServiceChecks) && fromJSON(steps.services-check.outputs.make_pr)
|
|
with:
|
|
author: 'Service Checker <commits@obsproject.com>'
|
|
commit-message: 'rtmp-services: Remove defunct servers/services'
|
|
title: 'rtmp-services: Remove defunct servers/services'
|
|
branch: 'automated/clean-services'
|
|
body: ${{ fromJSON(steps.services-check.outputs.pr_message) }}
|
|
delete-branch: true
|