|
1 | | -## GitHub Action for Lagon |
| 1 | +# Lagon Action |
| 2 | + |
| 3 | +Easily integrate [Lagon](https://lagon.dev) CLI into your Github workflows. Deploy new functions, retrieve a list of existing functions, promote functions, etc. This action supports any [arbitrary input](#other-commands) of what to do! |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Create the following workflow in your function's repository: |
| 8 | + |
| 9 | +_./github/workflows/lagon.yml_ |
| 10 | + |
| 11 | +```yml |
| 12 | +name: Lagon |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + |
| 19 | +jobs: |
| 20 | + deploy: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + name: Deploy |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - uses: lagonapp/github-action@main |
| 26 | + with: |
| 27 | + lagon_token: ${{ secrets.LAGON_API_TOKEN }} |
| 28 | +``` |
| 29 | +
|
| 30 | +This will deploy your source code to the specified function after a commit is pushed into main. |
| 31 | +
|
| 32 | +_NOTE: Make sure the repository that gets checked out contains a `.lagon/config.json` file that specifies information such as the function_id and organization_id!_ |
| 33 | + |
| 34 | +#### Other commands |
| 35 | + |
| 36 | +If you want to run a different command just specify it with the `command` input: |
| 37 | + |
| 38 | +```bash |
| 39 | + with: |
| 40 | + lagon_token: ${{ secrets.LAGON_API_TOKEN }} |
| 41 | + command: "promote claxnlc230738q5pa7iximskm ./my-project" |
| 42 | +``` |
| 43 | + |
| 44 | +See [CLI](https://docs.lagon.app/cli) docs for more commands. |
| 45 | + |
| 46 | +## Inputs |
| 47 | + |
| 48 | +Inputs are provided using the `with:` section of your workflow YML file. |
| 49 | + |
| 50 | +| key | Description | Required | Default | |
| 51 | +| ----------- | ---------------------------- | -------- | ---------------------- | |
| 52 | +| lagon_token | Your Lagon API token | true | | |
| 53 | +| command | The Lagon CLI command to run | false | deploy --prod | |
| 54 | +| site_url | Specify Lagon API domain | false | https://dash.lagon.app | |
| 55 | + |
| 56 | +`site_url` is used to specify a custom endpoint if you are using a self-hosted instance of Lagon. |
| 57 | + |
| 58 | +## Outputs |
| 59 | + |
| 60 | +| key | Description | Nullable | |
| 61 | +| --- | ----------- | -------- | |
| 62 | +| | | | |
| 63 | + |
| 64 | +No outputs for now... not sure what the CLI can output, function hash ? |
| 65 | + |
| 66 | +## Developing |
| 67 | + |
| 68 | +Install [act](https://github.com/nektos/act) then push your action changes to a branch on Github if you want to test the changes you made. Unfortunately, you have to push your changes to Github for this test runner to work. |
| 69 | + |
| 70 | +**Make sure to export `LAGON_API_TOKEN` so the action can configure the CLI! This is normally populated by Github.** |
| 71 | + |
| 72 | +Once you have pushed the changes you want to test you can now run it locally with the provided [test.sh](/test.sh) script like so: |
| 73 | + |
| 74 | +```bash |
| 75 | +# Usage: ./test.sh -f path_to_function [-r repo, -c command, -s site_url] |
| 76 | +
|
| 77 | +# Test the main branch with a local function project |
| 78 | +./test.sh -f ~/Projects/lagon-function |
| 79 | +
|
| 80 | +# Test a development branch |
| 81 | +./test.sh -r lagonapp/github-action@my-dev-branch -f ~/Projects/lagon-function |
| 82 | +
|
| 83 | +# You can also specify the command and site_url |
| 84 | +# See the inputs table for more info on the commands |
| 85 | +./test.sh -r lagonapp/github-action@my-dev-branch \ |
| 86 | + -f ~/Projects/lagon-function \ |
| 87 | + -c "ls" \ |
| 88 | + -s "https://lagon.mysite.io" |
| 89 | +``` |
0 commit comments