Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/workflow-utils.test.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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'));
});
});
16 changes: 9 additions & 7 deletions templates/defang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' }}
Loading