Skip to content

Commit e05de97

Browse files
committed
update yaml parsing in wfl
1 parent 837e2f2 commit e05de97

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

.github/workflows/deploy-ecosystem.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,30 @@ jobs:
5252
with:
5353
fetch-depth: 0
5454

55-
- name: Setup Node.js (for reading YAML config)
56-
uses: actions/setup-node@v4
57-
with:
58-
node-version: '20'
59-
cache: 'npm'
60-
61-
- name: Install js-yaml (pinned)
62-
run: npm i js-yaml@4 --no-save
55+
- name: Install yq
56+
uses: mikefarah/yq@v4.44.3
6357

64-
- name: Read deployment config
58+
- name: Convert deployment config YAML to JSON
6559
id: config
66-
uses: actions/github-script@v7
67-
with:
68-
github-token: ${{ secrets.GITHUB_TOKEN }}
69-
script: |
70-
const fs = require('fs');
71-
const yaml = require('js-yaml');
72-
73-
const configPath = '.github/deploy-ecosystem-configs.yml';
74-
const configContent = fs.readFileSync(configPath, 'utf8');
75-
const config = yaml.load(configContent);
76-
77-
core.setOutput('config', JSON.stringify(config));
60+
run: |
61+
yq -o=json '.'
62+
yq -o=json '.' .github/deploy-ecosystem-configs.yml > /tmp/deploy-config.json
63+
echo "config_json<<EOF" >> "$GITHUB_OUTPUT"
64+
cat /tmp/deploy-config.json >> "$GITHUB_OUTPUT"
65+
echo "EOF" >> "$GITHUB_OUTPUT"
7866
7967
- name: Filter projects based on changes
8068
id: filter
8169
uses: actions/github-script@v7
8270
env:
83-
DEPLOY_CONFIG_JSON: ${{ steps.config.outputs.config }}
71+
DEPLOY_CONFIG_JSON: ${{ steps.config.outputs.config_json }}
8472
with:
8573
github-token: ${{ secrets.GITHUB_TOKEN }}
8674
script: |
8775
const { execSync } = require('child_process');
8876
const config = JSON.parse(process.env.DEPLOY_CONFIG_JSON);
8977
78+
// Manual trigger: deploy specific project or all
9079
if ('${{ github.event_name }}' === 'workflow_dispatch') {
9180
if ('${{ inputs.project_name }}') {
9281
const project = config.projects.find(p => p.name === '${{ inputs.project_name }}');
@@ -103,6 +92,7 @@ jobs:
10392
}
10493
}
10594
95+
// Get changed files (only for push events)
10696
let changedFiles = [];
10797
if ('${{ github.event_name }}' === 'push') {
10898
try {
@@ -111,11 +101,13 @@ jobs:
111101
.trim()
112102
.split('\n')
113103
.filter(Boolean);
114-
} catch {
104+
} catch (error) {
105+
// If git diff fails, deploy all projects
115106
changedFiles = ['ecosystem/'];
116107
}
117108
}
118109
110+
// Find projects with changed files, or if workflow/config changed
119111
const workflowChanged = changedFiles.some(f =>
120112
f.includes('deploy-ecosystem') || f.includes('deploy-ecosystem-configs')
121113
);

0 commit comments

Comments
 (0)