Skip to content

Commit 27c61b3

Browse files
committed
Add command input param
1 parent 0ea1c89 commit 27c61b3

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
2727
### Managing Config Values
2828
29-
Defang allows you to [securely manage configuration values](https://docs.defang.io/docs/concepts/configuration). You can store your config using [GitHub Actions Secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) and then pass them through to the Defang action.
29+
Defang allows you to [securely manage configuration values](https://docs.defang.io/docs/concepts/configuration). You can store your config using [GitHub Actions Secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) and then pass them through to the Defang action.
3030
3131
To publish a secret stored in GitHub to the cloud as a secure config value with defang, you need to do two things:
3232
@@ -83,6 +83,23 @@ jobs:
8383
cli-version: v0.5.38
8484
```
8585

86+
### Customizing the Defang Command
87+
88+
If you want to customize the Defang command that is run, you can specify it using the `command` input.
89+
This is useful if you want to run a command other than `compose up` or if you want to pass additional arguments to the command.
90+
91+
```yaml
92+
jobs:
93+
test:
94+
# [...]
95+
steps:
96+
# [...]
97+
- name: Deploy
98+
uses: DefangLabs/[email protected]
99+
with:
100+
command: "compose up --project-name my-project"
101+
```
102+
86103
### Full Example
87104

88105
Here is a full example of a GitHub workflow that does everything we've discussed so far:

action.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ inputs:
2727
required: false
2828
default: ""
2929
provider:
30-
description: "The cloud provider to deploy to. Options: 'aws', 'defang'"
30+
description: "The cloud provider to deploy to. Options: 'aws', 'defang', 'digitalocean'"
3131
required: false
3232
default: "defang"
33+
command:
34+
description: "The command to run."
35+
required: false
36+
default: "compose up"
3337

3438
runs:
3539
using: "composite"
@@ -55,6 +59,7 @@ runs:
5559
5660
- name: Defang Config Set
5761
shell: bash
62+
if: ${{ inputs['config-env-vars'] != "" }}
5863
run: |
5964
# Iterate over the sources and set the environment variables
6065
params=()
@@ -71,7 +76,8 @@ runs:
7176
env:
7277
CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }}
7378

74-
- name: Defang Compose Up
79+
- name: Defang ${{ inputs['command'] }}
80+
if: ${{ inputs['command'] != "" }}
7581
shell: bash
7682
working-directory: ${{ inputs.cwd }}
7783
run: |
@@ -85,10 +91,11 @@ runs:
8591
fi
8692
8793
if [[ "${DEFANG_INTERNAL_TEST}" == "dfng-test" ]]; then
88-
# `defang compose up --dry-run` is used for testing as --mode flag is only available to the "compose up" command
89-
echo defang compose "${params[@]}" up --dry-run
90-
defang compose "${params[@]}" up --dry-run
91-
else
92-
echo defang compose "${params[@]}" up
93-
defang compose "${params[@]}" up
94+
# `--dry-run` is used for testing as --mode flag is only available to the "compose up" command
95+
params+=("--dry-run")
9496
fi
97+
98+
echo defang $COMMAND "${params[@]}"
99+
defang $COMMAND "${params[@]}"
100+
env:
101+
COMMAND: ${{ inputs['command'] }}

0 commit comments

Comments
 (0)