|
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@latest |
| 26 | + with: |
| 27 | + lagon_token: ${{ secrets.LAGON_API_TOKEN }} |
| 28 | + - name: Log Function URL |
| 29 | + run: | |
| 30 | + url=$(grep -o 'https://[^[:space:]]*' lagon.output) |
| 31 | + echo "Function available at: $url" |
| 32 | +``` |
| 33 | +
|
| 34 | +This will deploy your source code to the specified function after a commit is pushed into main. |
| 35 | +
|
| 36 | +_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 or pass in a config via the config input value mentioned below!_ |
| 37 | + |
| 38 | +#### Other commands |
| 39 | + |
| 40 | +If you want to run a different command just specify it with the `command` input: |
| 41 | + |
| 42 | +```bash |
| 43 | + with: |
| 44 | + lagon_token: ${{ secrets.LAGON_API_TOKEN }} |
| 45 | + command: ls |
| 46 | +``` |
| 47 | + |
| 48 | +See [CLI](https://docs.lagon.app/cli) docs for more commands. |
| 49 | + |
| 50 | +## Inputs |
| 51 | + |
| 52 | +Inputs are provided using the `with:` section of your workflow YML file. |
| 53 | + |
| 54 | +| key | Description | Required | Default | |
| 55 | +| ----------- | ---------------------------- | -------- | ---------------------- | |
| 56 | +| lagon_token | Your Lagon API token | true | | |
| 57 | +| command | The Lagon CLI command to run | false | deploy --prod | |
| 58 | +| site_url | Specify Lagon API domain | false | https://dash.lagon.app | |
| 59 | +| config | Config file for function | false | | |
| 60 | + |
| 61 | +`site_url` is used to specify a custom endpoint if you are using a self-hosted instance of Lagon. |
| 62 | + |
| 63 | +`config` allows you to override a repositories existing config or maybe it never existed because you didn't want to commit it: |
| 64 | + |
| 65 | +```bash |
| 66 | + with: |
| 67 | + lagon_token: ${{ secrets.LAGON_API_TOKEN }} |
| 68 | + config: | |
| 69 | + { |
| 70 | + "function_id": "${{ vars.lagon_function_id }}", |
| 71 | + "organization_id": "${{ vars.lagon_org_id }}", |
| 72 | + "index": "hello.ts", |
| 73 | + "client": null, |
| 74 | + "assets": null |
| 75 | + } |
| 76 | +``` |
| 77 | + |
| 78 | +This example is setting the function and org ID with [variables](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository). |
| 79 | + |
| 80 | +## Outputs |
| 81 | + |
| 82 | +Since the action allows you to run any command, there are no outputs. Instead, the CLI stdout will be saved to a local file called `lagon.output`. |
0 commit comments