From f16b92d1680e41d70c8d321b48614d911771a2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Titsworth-Morin?= Date: Wed, 17 Jun 2026 15:38:06 +0000 Subject: [PATCH] fix(samples): pass project and stack to sample workflows --- scripts/workflow-utils.test.js | 12 +++++++++++- templates/defang.yaml | 16 +++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/workflow-utils.test.js b/scripts/workflow-utils.test.js index 648785c4..80dff5f8 100644 --- a/scripts/workflow-utils.test.js +++ b/scripts/workflow-utils.test.js @@ -1,6 +1,6 @@ const { describe, it } = require('node:test'); const assert = require('node:assert'); -const { isRandomSecret, extractSecretsFromCompose, generateWorkflow } = require('./workflow-utils'); +const { isRandomSecret, extractSecretsFromCompose, generateWorkflow, loadWorkflowTemplate } = require('./workflow-utils'); describe('isRandomSecret', () => { it('should classify PASSWORD as random', () => { @@ -247,4 +247,14 @@ jobs: assert.ok(!result.includes('config-env-vars')); assert.ok(!result.includes('env:')); }); + + it('should keep project and production stack inputs in the canonical template', () => { + const secrets = { random: [], userProvided: [] }; + const result = generateWorkflow(loadWorkflowTemplate(), secrets); + + assert.ok(result.includes('project: ${{ github.event.repository.name }}')); + assert.ok(result.includes("stack: ${{ github.event.inputs.stack || 'production' }}")); + assert.ok(!result.includes("stack: ${{ github.event.inputs.stack || '' }}")); + assert.ok(!result.includes('default stack')); + }); }); diff --git a/templates/defang.yaml b/templates/defang.yaml index 873813f3..1e7895af 100644 --- a/templates/defang.yaml +++ b/templates/defang.yaml @@ -15,12 +15,12 @@ on: - up - down stack: - description: "The stack to deploy up or down. (Leave blank for default)" - default: "" + description: "The stack to deploy up or down." + default: "production" jobs: defang: - name: Defang ${{ github.event.inputs.action || 'up' }} ${{ github.event.inputs.stack || 'default stack' }} + name: Defang ${{ github.event.inputs.action || 'up' }} ${{ github.event.inputs.stack || 'production' }} environment: defang-${{ github.event.inputs.stack || 'production' }} runs-on: ubuntu-latest timeout-minutes: 70 @@ -30,20 +30,22 @@ jobs: concurrency: cancel-in-progress: false - group: deploy-${{ github.event.inputs.stack || 'default' }} + group: deploy-${{ github.event.inputs.stack || 'production' }} steps: - name: Checkout Repo uses: actions/checkout@v4 - - name: Defang ${{ github.event.inputs.action || 'up' }} ${{ github.event.inputs.stack || 'default stack' }} + - name: Defang ${{ github.event.inputs.action || 'up' }} ${{ github.event.inputs.stack || 'production' }} uses: DefangLabs/defang-github-action@v2 with: command: ${{ github.event.inputs.action || 'up' }} - stack: ${{ github.event.inputs.stack || '' }} + project: ${{ github.event.repository.name }} + stack: ${{ github.event.inputs.stack || 'production' }} - name: Deployment Summary uses: DefangLabs/defang-github-action@v2 with: command: services - stack: ${{ github.event.inputs.stack || '' }} + project: ${{ github.event.repository.name }} + stack: ${{ github.event.inputs.stack || 'production' }}