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