Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ on:
push:
branches:
- main
- "**"
pull_request:
branches:
- "**"
workflow_dispatch:
# schedule:
# - cron: "0 0 * * *" # daily at midnight
Expand Down Expand Up @@ -42,6 +39,13 @@ jobs:
DEFANG_GH_ACTION_TEST_ENV: "foo"
DEFANG_GH_ACTION_TEST_MESSAGE: ${{ secrets.MESSAGE }}

- name: Deploy from Git ref
uses: ./
with:
cli-version: main
cwd: "./test"
command: "config help"

- name: Deploy-Empty-Params
uses: ./
continue-on-error: true # Ignore dry run error
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ jobs:

### Specifying the CLI Version

If you want to use a specific version of the Defang CLI, you can specify it using the `cli-version` input. Specify a version number, or `nightly` to use the nightly CLI build. Note that the nightly builds have only undergone limited automated testing and should be considered unstable.
If you want to use a specific version of the Defang CLI, you can specify it using the `cli-version` input.
Specify a version number (with or without `v`), or `nightly` to use the nightly CLI build.
Note that the nightly builds have only undergone limited automated testing and should be considered unstable.
You can also pass any Git ref (branch name like `main` or commit SHA) to build the CLI from source using `go`.

```yaml
jobs:
Expand All @@ -88,7 +91,7 @@ jobs:
- name: Deploy
uses: DefangLabs/defang-github-action@v2
with:
cli-version: v2.10.0
cli-version: v3.5.2 # or 3.5.2 or nightly or main or a commit SHA
```

### Customizing the Defang Command
Expand Down Expand Up @@ -134,7 +137,7 @@ jobs:
- name: Deploy
uses: DefangLabs/defang-github-action@v2
with:
cli-version: v2.10.0
cli-version: v3.5.2
config-env-vars: "API_KEY DB_CONNECTION_STRING"
cwd: "./test"
compose-files: "./docker-compose.yaml"
Expand Down
25 changes: 24 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ branding:

inputs:
cli-version:
description: "The version of the Defang CLI to use. Defaults to the latest stable release."
description: "The version or Git ref of the Defang CLI to use. Defaults to the latest stable release."
required: false
default: ""
config-env-vars:
Expand Down Expand Up @@ -63,6 +63,29 @@ outputs:
runs:
using: "composite"
steps:
# If cli-version is a Git ref (not empty, not "nightly", and no dots, eg. no "v1.2.3"),
# build the CLI from source instead of downloading a release.
- name: Checkout CLI repository
id: checkout-cli
if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.')
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: DefangLabs/defang
ref: ${{ inputs.cli-version }}
path: defang-cli

- name: Setup Go
if: steps.checkout-cli.outcome == 'success'
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: defang-cli/src/go.mod
cache-dependency-path: defang-cli/src/go.sum

- name: Build CLI from source
if: steps.checkout-cli.outcome == 'success'
shell: bash
run: cd defang-cli/src && go build -o "$RUNNER_TOOL_CACHE/defang" ./cmd/cli && echo "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH"

- name: Install defang
shell: bash
run: |
Expand Down
Loading