Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optionally register your local workflow #1

Merged
merged 2 commits into from
May 16, 2023
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
24 changes: 24 additions & 0 deletions .github/workflows/example-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Example 1: Basic usage"

on:
pull_request:
branches:
- "*"
push:
branches:
- "develop"
- "main"

jobs:
example-1:
runs-on: ubuntu-latest
name: A job to setup latch
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- id: latch
uses: fulcrumgenomics/setup-latch@v1
- run: echo latch version ${{ steps.latch.outputs.latch-version }}
shell: bash
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# `fulcrumgenomics/setup-latch`

This action sets up the [`latch`](https://github.com/latchbio/latch) CLI and SDK.
Visit https://docs.latch.bio to learn more about `latch`.

By default, this action will setup ssh config in `~/.ssh/config` for `latch` commands that require ssh by disabling strict host key checking (`StrictHostKeyChecking No` for all hosts in the `~/.ssh/config`).

The action will optional add the provided latch workspace identifier and token to `~/.latch/workspace` and `~/.latch/token` files respectively.
This is used when registering your local workflow code to Latch (see the `register*` inputs).

Finally, the `latch` package is installed.

Expand All @@ -15,6 +17,10 @@ For a full list of available _inputs_ and _outputs_ for this action see

## Usage example

### Example 1: Basic usage

This example shows how to install the latest version of `latch` and echo the version installed.

```yaml
jobs:
setup-latch-job:
Expand All @@ -31,3 +37,28 @@ jobs:
shell: bash
```

### Example 2: Register your local workflow code to Latch

This example shows how to register your local workflow code to Latch.
The `workspace` and `token` are required and accept the workspace identifier and developer token respectively.
In this example, they are stored as [encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets).

```yaml
jobs:
setup-latch-job:
runs-on: ubuntu-latest
name: A job to setup latch
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- id: latch
uses: fulcrumgenomics/setup-latch@v1
with:
workspace: ${{ secrets.LATCH_WORKSPACE }}
token: ${{ secrets.LATCH_TOKEN }}
register: true
- run: echo latch version ${{ steps.latch.outputs.latch-version }}
shell: bash
```
33 changes: 32 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,26 @@ inputs:
required: false
default: ""
ssh-config:
desecription: "Set up the ~/.ssh directory."
description: "Set up the ~/.ssh directory."
required: false
default: true
register:
description: "Register repository workflow code to Latch. Visit docs.latch.bio to learn more."
required: false
default: false
register-pkg-root:
description: "The relative path to the root of the package to register"
required: false
default: "."
register-remote:
description: "Use a remote server to build workflow."
required: false
default: true
register-disable-auto-version:
description: "Whether to automatically bump the version of the workflow each time register is called."
required: false
default: false


outputs:
latch-version:
Expand Down Expand Up @@ -63,4 +81,17 @@ runs:
shell: bash
run: |
echo "latch-version=$(latch --version | cut -f 3 -d ' ')" >> $GITHUB_OUTPUT
- id: latch-register
shell: bash
if: ${{ inputs.register }} == 'true'
run: |
eval `ssh-agent -s`
args=${{ inputs.register-pkg-root }}
if [ ${{ inputs.register-remote }} == "true" ]; then
args="--remote ${args}"
fi
if [ ${{ inputs.register-register-disable-auto-version }} == "true" ]; then
args="--register-disable-auto-version ${args}"
fi
latch register --yes ${args}