From e6348f655498106642a58c983ab3cfb2bf38a409 Mon Sep 17 00:00:00 2001 From: panicboat Date: Fri, 9 Oct 2026 15:56:00 +0900 Subject: [PATCH 1/2] fix: run scripts directly from action path without checking out deploy-actions Signed-off-by: panicboat --- label-dispatcher/action.yaml | 35 ++++++-------------------- label-dispatcher/copy-configuration.js | 30 ---------------------- label-resolver/action.yaml | 34 +++++-------------------- label-resolver/copy-configuration.js | 30 ---------------------- 4 files changed, 13 insertions(+), 116 deletions(-) delete mode 100644 label-dispatcher/copy-configuration.js delete mode 100644 label-resolver/copy-configuration.js diff --git a/label-dispatcher/action.yaml b/label-dispatcher/action.yaml index 049783c..4e09ec6 100644 --- a/label-dispatcher/action.yaml +++ b/label-dispatcher/action.yaml @@ -20,14 +20,6 @@ inputs: description: 'Path to workflow configuration file' required: false default: 'workflow-config.yaml' - deploy-actions-repository: - description: 'Deploy actions repository to use' - required: false - default: 'panicboat/deploy-actions' - deploy-actions-ref: - description: 'Ref (branch, tag, or SHA) of deploy-actions to checkout' - required: false - default: '' outputs: labels-added: @@ -46,13 +38,6 @@ outputs: runs: using: 'composite' steps: - - name: Checkout deploy-actions - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: ${{ inputs.deploy-actions-repository }} - ref: ${{ inputs.deploy-actions-ref || github.action_ref }} - path: deploy-actions - - name: Checkout source repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -66,36 +51,30 @@ runs: with: ruby-version: '4.0.7' bundler-cache: true - working-directory: deploy-actions/action-scripts - - - name: Copy configuration from source repository - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const path = require('path'); - const copyConfiguration = require(path.join(process.env.GITHUB_ACTION_PATH, 'copy-configuration.js')); - await copyConfiguration({ core, inputs: ${{ toJSON(inputs) }} }); + working-directory: ${{ github.action_path }}/../action-scripts - name: Validate configuration shell: bash - working-directory: deploy-actions/action-scripts + working-directory: ${{ github.action_path }}/../action-scripts run: | echo "🔍 Validating configuration file" bundle exec ruby config-manager/bin/config-manager validate env: - WORKFLOW_CONFIG_PATH: workflow-config.yaml + WORKFLOW_CONFIG_PATH: ${{ github.workspace }}/source-repo/${{ inputs.config-path }} + SOURCE_REPO_PATH: ${{ github.workspace }}/source-repo - name: Dispatch labels id: dispatch shell: bash - working-directory: deploy-actions/action-scripts + working-directory: ${{ github.action_path }}/../action-scripts run: | echo "🚀 Starting label dispatch for PR #${{ inputs.pr-number }}" bundle exec ruby label-dispatcher/bin/dispatcher dispatch ${{ inputs.pr-number }} env: GITHUB_TOKEN: ${{ inputs.github-token }} GITHUB_REPOSITORY: ${{ inputs.repository }} - WORKFLOW_CONFIG_PATH: workflow-config.yaml + WORKFLOW_CONFIG_PATH: ${{ github.workspace }}/source-repo/${{ inputs.config-path }} + SOURCE_REPO_PATH: ${{ github.workspace }}/source-repo - name: Report results if: always() diff --git a/label-dispatcher/copy-configuration.js b/label-dispatcher/copy-configuration.js deleted file mode 100644 index 89c100a..0000000 --- a/label-dispatcher/copy-configuration.js +++ /dev/null @@ -1,30 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -module.exports = async ({ core, inputs }) => { - try { - core.info('📋 Copying configuration from source repository'); - - const configPath = inputs['config-path']; - const sourcePath = `source-repo/${configPath}`; - const targetPath = 'deploy-actions/action-scripts/workflow-config.yaml'; - - core.info(`Source path: ${sourcePath}`); - core.info(`Target path: ${targetPath}`); - - // Check if source file exists - if (!fs.existsSync(sourcePath)) { - core.setFailed(`Configuration file not found: ${configPath}`); - return; - } - - // Copy file - fs.copyFileSync(sourcePath, targetPath); - - core.info('✅ Configuration copied successfully'); - - } catch (error) { - core.setFailed(`Configuration copy failed: ${error.message}`); - throw error; - } -}; diff --git a/label-resolver/action.yaml b/label-resolver/action.yaml index cfacf98..ff93211 100644 --- a/label-resolver/action.yaml +++ b/label-resolver/action.yaml @@ -23,14 +23,6 @@ inputs: description: 'Path to workflow configuration file' required: false default: 'workflow-config.yaml' - deploy-actions-repository: - description: 'Deploy actions repository to use' - required: false - default: 'panicboat/deploy-actions' - deploy-actions-ref: - description: 'Ref (branch, tag, or SHA) of deploy-actions to checkout' - required: false - default: '' outputs: targets: @@ -46,13 +38,6 @@ outputs: runs: using: 'composite' steps: - - name: Checkout deploy-actions - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: ${{ inputs.deploy-actions-repository }} - ref: ${{ inputs.deploy-actions-ref || github.action_ref }} - path: deploy-actions - - name: Checkout source repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -65,29 +50,22 @@ runs: with: ruby-version: '4.0.7' bundler-cache: true - working-directory: deploy-actions/action-scripts - - - name: Copy configuration from source repository - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const path = require('path'); - const copyConfiguration = require(path.join(process.env.GITHUB_ACTION_PATH, 'copy-configuration.js')); - await copyConfiguration({ core, inputs: ${{ toJSON(inputs) }} }); + working-directory: ${{ github.action_path }}/../action-scripts - name: Validate configuration shell: bash - working-directory: deploy-actions/action-scripts + working-directory: ${{ github.action_path }}/../action-scripts run: | echo "🔍 Validating configuration file" bundle exec ruby config-manager/bin/config-manager validate env: - WORKFLOW_CONFIG_PATH: workflow-config.yaml + WORKFLOW_CONFIG_PATH: ${{ github.workspace }}/source-repo/${{ inputs.config-path }} + SOURCE_REPO_PATH: ${{ github.workspace }}/source-repo - name: Resolve deployment targets id: extract shell: bash - working-directory: deploy-actions/action-scripts + working-directory: ${{ github.action_path }}/../action-scripts run: | echo "🚀 Starting deployment target resolution" echo "PR: ${{ inputs.pr-number }}" @@ -96,7 +74,7 @@ runs: env: GITHUB_TOKEN: ${{ inputs.github-token }} GITHUB_REPOSITORY: ${{ inputs.repository }} - WORKFLOW_CONFIG_PATH: workflow-config.yaml + WORKFLOW_CONFIG_PATH: ${{ github.workspace }}/source-repo/${{ inputs.config-path }} SOURCE_REPO_PATH: ${{ github.workspace }}/source-repo - name: Parse deployment outputs diff --git a/label-resolver/copy-configuration.js b/label-resolver/copy-configuration.js deleted file mode 100644 index 89c100a..0000000 --- a/label-resolver/copy-configuration.js +++ /dev/null @@ -1,30 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -module.exports = async ({ core, inputs }) => { - try { - core.info('📋 Copying configuration from source repository'); - - const configPath = inputs['config-path']; - const sourcePath = `source-repo/${configPath}`; - const targetPath = 'deploy-actions/action-scripts/workflow-config.yaml'; - - core.info(`Source path: ${sourcePath}`); - core.info(`Target path: ${targetPath}`); - - // Check if source file exists - if (!fs.existsSync(sourcePath)) { - core.setFailed(`Configuration file not found: ${configPath}`); - return; - } - - // Copy file - fs.copyFileSync(sourcePath, targetPath); - - core.info('✅ Configuration copied successfully'); - - } catch (error) { - core.setFailed(`Configuration copy failed: ${error.message}`); - throw error; - } -}; From cf9d7df487ab511cd7843186ae1832ebd6a61907 Mon Sep 17 00:00:00 2001 From: panicboat Date: Fri, 9 Oct 2026 16:13:50 +0900 Subject: [PATCH 2/2] refactor: inline script reporting and remove separate js files Signed-off-by: panicboat --- label-dispatcher/action.yaml | 10 ++++-- label-dispatcher/report-results.js | 12 ------- label-resolver/action.yaml | 37 +++++++--------------- label-resolver/parse-deployment-outputs.js | 17 ---------- label-resolver/report-results.js | 14 -------- 5 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 label-dispatcher/report-results.js delete mode 100644 label-resolver/parse-deployment-outputs.js delete mode 100644 label-resolver/report-results.js diff --git a/label-dispatcher/action.yaml b/label-dispatcher/action.yaml index 4e09ec6..eeaaa10 100644 --- a/label-dispatcher/action.yaml +++ b/label-dispatcher/action.yaml @@ -79,8 +79,12 @@ runs: - name: Report results if: always() uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + REPOSITORY: ${{ inputs.repository }} + PR_NUMBER: ${{ inputs.pr-number }} with: script: | - const path = require('path'); - const reportResults = require(path.join(process.env.GITHUB_ACTION_PATH, 'report-results.js')); - await reportResults({ core, context, inputs: ${{ toJSON(inputs) }} }); + core.info('📊 Label dispatch completed'); + core.info(`Repository: ${process.env.REPOSITORY}`); + core.info(`PR Number: ${process.env.PR_NUMBER}`); + core.info(`Status: ${context.job.status || 'unknown'}`); diff --git a/label-dispatcher/report-results.js b/label-dispatcher/report-results.js deleted file mode 100644 index 2e089df..0000000 --- a/label-dispatcher/report-results.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = async ({ core, context, inputs }) => { - try { - core.info('📊 Label dispatch completed'); - core.info(`Repository: ${inputs.repository}`); - core.info(`PR Number: ${inputs['pr-number']}`); - core.info(`Status: ${context.job.status || 'unknown'}`); - - } catch (error) { - core.setFailed(`Report generation failed: ${error.message}`); - throw error; - } -}; diff --git a/label-resolver/action.yaml b/label-resolver/action.yaml index ff93211..649abb4 100644 --- a/label-resolver/action.yaml +++ b/label-resolver/action.yaml @@ -77,35 +77,22 @@ runs: WORKFLOW_CONFIG_PATH: ${{ github.workspace }}/source-repo/${{ inputs.config-path }} SOURCE_REPO_PATH: ${{ github.workspace }}/source-repo - - name: Parse deployment outputs - id: parse + - name: Report results + if: always() uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: + REPOSITORY: ${{ inputs.repository }} + PR_NUMBER: ${{ inputs.pr-number }} + TARGET_ENVIRONMENTS: ${{ inputs.environments }} DEPLOYMENT_TARGETS: ${{ steps.extract.outputs.targets }} HAS_TARGETS: ${{ steps.extract.outputs.has-targets }} SAFETY_STATUS: ${{ steps.extract.outputs.safety-status }} with: script: | - const path = require('path'); - const parseOutputs = require(path.join(process.env.GITHUB_ACTION_PATH, 'parse-deployment-outputs.js')); - await parseOutputs({ core, context }); - - - name: Report results - if: always() - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const path = require('path'); - const reportResults = require(path.join(process.env.GITHUB_ACTION_PATH, 'report-results.js')); - await reportResults({ - core, - inputs: ${{ toJSON(inputs) }}, - steps: { - extract: { - outputs: { - 'has-targets': '${{ steps.extract.outputs.has-targets }}', - 'safety-status': '${{ steps.extract.outputs.safety-status }}' - } - } - } - }); + core.info('📊 Label Resolver completed'); + core.info(`Repository: ${process.env.REPOSITORY}`); + core.info(`PR Number: ${process.env.PR_NUMBER}`); + core.info(`Target Environments: ${process.env.TARGET_ENVIRONMENTS || 'all'}`); + core.info(`Deployment Targets: ${process.env.DEPLOYMENT_TARGETS || '[]'}`); + core.info(`Has Targets: ${process.env.HAS_TARGETS || 'false'}`); + core.info(`Safety Status: ${process.env.SAFETY_STATUS || 'unknown'}`); diff --git a/label-resolver/parse-deployment-outputs.js b/label-resolver/parse-deployment-outputs.js deleted file mode 100644 index b9b19e7..0000000 --- a/label-resolver/parse-deployment-outputs.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = async ({ core, context }) => { - try { - core.info('📊 Parsing deployment outputs'); - - const deploymentTargets = process.env.DEPLOYMENT_TARGETS || '[]'; - const hasTargets = process.env.HAS_TARGETS || 'false'; - const safetyStatus = process.env.SAFETY_STATUS || 'unknown'; - - core.info(`DEPLOYMENT_TARGETS: ${deploymentTargets}`); - core.info(`HAS_TARGETS: ${hasTargets}`); - core.info(`SAFETY_STATUS: ${safetyStatus}`); - - } catch (error) { - core.setFailed(`Deployment output parsing failed: ${error.message}`); - throw error; - } -}; diff --git a/label-resolver/report-results.js b/label-resolver/report-results.js deleted file mode 100644 index 813b568..0000000 --- a/label-resolver/report-results.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = async ({ core, inputs, steps }) => { - try { - core.info('📊 Label Resolver completed'); - core.info(`Repository: ${inputs.repository}`); - core.info(`PR Number: ${inputs['pr-number']}`); - core.info(`Target Environments: ${inputs['target-environments'] || 'all'}`); - core.info(`Has Targets: ${steps.extract.outputs['has-targets']}`); - core.info(`Safety Status: ${steps.extract.outputs['safety-status']}`); - - } catch (error) { - core.setFailed(`Report generation failed: ${error.message}`); - throw error; - } -};