mirror of
https://github.com/immich-app/immich.git
synced 2025-08-11 09:16:31 -04:00
chore: nits and cleanup
This commit is contained in:
parent
f7eeafb228
commit
5cea70120e
23
.github/actions/pre-job/action.yml
vendored
23
.github/actions/pre-job/action.yml
vendored
@ -21,12 +21,11 @@ inputs:
|
||||
required: false
|
||||
default: ''
|
||||
skip-force-logic:
|
||||
description: 'Skip the standard force logic (for special cases like weblate)'
|
||||
description: 'Skip the standard force logic'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
outputs:
|
||||
# Individual outputs that can be accessed directly
|
||||
should_run:
|
||||
description: 'Nested object with filter results (access via fromJSON(steps.pre-job.outputs.should_run).filter_name)'
|
||||
value: ${{ steps.generate-outputs.outputs.should_run }}
|
||||
@ -34,8 +33,8 @@ outputs:
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Convert filters to JSON
|
||||
id: convert-filters
|
||||
- name: List filter keys as comma-separated string
|
||||
id: list-filters
|
||||
shell: python
|
||||
env:
|
||||
FILTERS: ${{ inputs.filters }}
|
||||
@ -55,13 +54,12 @@ runs:
|
||||
if not isinstance(filters_dict, dict):
|
||||
raise ValueError("Filters must be a YAML dictionary")
|
||||
|
||||
# Just pass the filter names as a comma-separated string
|
||||
filter_names = ','.join(filters_dict.keys())
|
||||
|
||||
print(f"Filter names: {filter_names}")
|
||||
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
||||
f.write(f"filter_names={filter_names}\n")
|
||||
f.write(f"filters={filter_names}\n")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error converting filters: {e}")
|
||||
@ -75,7 +73,7 @@ runs:
|
||||
force-branches: ${{ inputs.force-branches }}
|
||||
exclude-branches: ${{ inputs.exclude-branches }}
|
||||
skip-force-logic: ${{ inputs.skip-force-logic }}
|
||||
filters-json: ${{ steps.convert-filters.outputs.filter_names }}
|
||||
filters-list: ${{ steps.list-filters.outputs.filters }}
|
||||
script: |
|
||||
const script = require('./.github/actions/pre-job/check-conditions.js')
|
||||
script({ core, context })
|
||||
@ -97,7 +95,6 @@ runs:
|
||||
import os
|
||||
import yaml
|
||||
|
||||
# Get the force filters input
|
||||
force_filters_input = os.environ.get('FORCE_FILTERS', '').strip()
|
||||
|
||||
if not force_filters_input:
|
||||
@ -105,10 +102,8 @@ runs:
|
||||
exit(0)
|
||||
|
||||
try:
|
||||
# Parse the force-filters as YAML - should be an array of paths
|
||||
force_paths_list = yaml.safe_load(force_filters_input)
|
||||
|
||||
# Ensure it's a list
|
||||
if not isinstance(force_paths_list, list):
|
||||
raise ValueError("force-filters must be a YAML array of paths")
|
||||
|
||||
@ -116,18 +111,14 @@ runs:
|
||||
print("No valid paths found in force-filters")
|
||||
exit(0)
|
||||
|
||||
# Create the YAML structure for paths-filter
|
||||
force_paths_config = {
|
||||
'force-paths': force_paths_list
|
||||
}
|
||||
|
||||
# Generate YAML string directly
|
||||
force_paths_yaml = yaml.dump(force_paths_config, default_flow_style=False)
|
||||
|
||||
print("Generated force paths YAML:")
|
||||
print(force_paths_yaml)
|
||||
print(f"Generated force paths YAML: {force_paths_yaml}")
|
||||
|
||||
# Set GitHub Actions output
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
||||
f.write(f"force-paths-yaml<<EOF\n{force_paths_yaml}EOF\n")
|
||||
|
||||
@ -154,7 +145,7 @@ runs:
|
||||
id: generate-outputs
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
with:
|
||||
filters-json: ${{ steps.convert-filters.outputs.filter_names }}
|
||||
filters-list: ${{ steps.list-filters.outputs.filters }}
|
||||
skip-force-logic: ${{ inputs.skip-force-logic }}
|
||||
force-triggered: ${{ steps.check-conditions.outputs.force_triggered }}
|
||||
should-skip: ${{ steps.check-conditions.outputs.should_skip }}
|
||||
|
14
.github/actions/pre-job/check-conditions.js
vendored
14
.github/actions/pre-job/check-conditions.js
vendored
@ -1,7 +1,6 @@
|
||||
module.exports = ({ core, context }) => {
|
||||
console.log('=== Pre-Job: Checking Conditions ===');
|
||||
|
||||
// Get inputs directly from core
|
||||
const forceEvents = core
|
||||
.getInput('force-events')
|
||||
.split(',')
|
||||
@ -17,17 +16,16 @@ module.exports = ({ core, context }) => {
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
const skipForceLogic = core.getInput('skip-force-logic') === 'true';
|
||||
const filtersJson = core.getInput('filters-json');
|
||||
const skipForceLogic = core.getBooleanInput('skip-force-logic');
|
||||
const filtersList = core.getInput('filters-list');
|
||||
|
||||
// Parse filter names from comma-separated string
|
||||
let filterNames = [];
|
||||
try {
|
||||
if (!filtersJson || !filtersJson.trim()) {
|
||||
throw new Error('filters-json input is required and cannot be empty');
|
||||
if (!filtersList || !filtersList.trim()) {
|
||||
throw new Error('filters-list input is required and cannot be empty');
|
||||
}
|
||||
|
||||
filterNames = filtersJson
|
||||
filterNames = filtersList
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
@ -40,9 +38,7 @@ module.exports = ({ core, context }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get GitHub context
|
||||
const currentEvent = context.eventName;
|
||||
// Fix: Handle different ref types safely
|
||||
const currentBranch = context.ref?.startsWith('refs/heads/')
|
||||
? context.ref.replace('refs/heads/', '')
|
||||
: context.ref || '';
|
||||
|
23
.github/actions/pre-job/generate-outputs.js
vendored
23
.github/actions/pre-job/generate-outputs.js
vendored
@ -1,18 +1,14 @@
|
||||
// No longer need YAML parser - using JSON from Python conversion
|
||||
module.exports = ({ core }) => {
|
||||
console.log('=== Pre-Job: Generating Final Outputs ===');
|
||||
|
||||
try {
|
||||
// Get inputs directly from core
|
||||
const filtersJson = core.getInput('filters-json');
|
||||
const skipForceLogic = core.getInput('skip-force-logic') === 'true';
|
||||
const filtersList = core.getInput('filters-list');
|
||||
const skipForceLogic = core.getBooleanInput('skip-force-logic');
|
||||
|
||||
// Get step outputs
|
||||
const forceTriggered = core.getInput('force-triggered') === 'true';
|
||||
const shouldSkip = core.getInput('should-skip') === 'true';
|
||||
const needsPathFiltering = core.getInput('needs-path-filtering') === 'true';
|
||||
const forceTriggered = core.getBooleanInput('force-triggered');
|
||||
const shouldSkip = core.getBooleanInput('should-skip');
|
||||
const needsPathFiltering = core.getBooleanInput('needs-path-filtering');
|
||||
|
||||
// Parse path results from separate steps
|
||||
let forcePathResults = {};
|
||||
let mainPathResults = {};
|
||||
|
||||
@ -37,11 +33,11 @@ module.exports = ({ core }) => {
|
||||
// Parse filter names from comma-separated string
|
||||
let filterNames = [];
|
||||
try {
|
||||
if (!filtersJson || !filtersJson.trim()) {
|
||||
throw new Error('filters-json input is required and cannot be empty');
|
||||
if (!filtersList || !filtersList.trim()) {
|
||||
throw new Error('filters-list input is required and cannot be empty');
|
||||
}
|
||||
|
||||
filterNames = filtersJson
|
||||
filterNames = filtersList
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
@ -77,7 +73,6 @@ module.exports = ({ core }) => {
|
||||
} else {
|
||||
console.log('📁 Generating PATH-BASED results');
|
||||
|
||||
// Check if force paths triggered (this forces ALL filters to true)
|
||||
const forcePathsTriggered = forcePathResults['force-paths'] === 'true';
|
||||
|
||||
if (forcePathsTriggered && !skipForceLogic) {
|
||||
@ -87,7 +82,6 @@ module.exports = ({ core }) => {
|
||||
}
|
||||
} else {
|
||||
console.log('📋 Using individual path results');
|
||||
// Process each filter based on main path results
|
||||
for (const filterName of filterNames) {
|
||||
const pathResult = mainPathResults[filterName] === 'true';
|
||||
results[filterName] = pathResult;
|
||||
@ -97,7 +91,6 @@ module.exports = ({ core }) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Output as JSON object that can be accessed with fromJSON()
|
||||
core.setOutput('should_run', JSON.stringify(results));
|
||||
|
||||
console.log('✅ Final results:', results);
|
||||
|
Loading…
x
Reference in New Issue
Block a user