diff --git a/README.md b/README.md index 3539a54..1d8d076 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,42 @@ -#OpenFN Github Deploy Action +# OpenFn GitHub Deploy Action -This action deploys to a specific Lightning instance whenever it is invoked. +Deploys an OpenFn project workspace to Lightning using `openfn project deploy`, +then commits the updated project state back to the branch. -It depends on an repository containing the following +The repository must contain an `openfn.yaml` workspace (as created by +`openfn project pull` or by Lightning's GitHub sync). Commit the `.openfn/` +folder: deploy uses it to detect changes made in Lightning since the last sync. -1. A `state.json` file which details ids and jobs in a project -2. A `project.yaml` file detailing a project its workflows, edges and triggers -3. A `config.json` file detailing a connection to a Lightning instance +`endpoint_input` is optional. Without it, the CLI uses the endpoint the +workspace already tracks for the project, then `OPENFN_ENDPOINT`, then +app.openfn.org. -Additionally one needs to pass in their OPENFN API KEY to the action as an input best way to do this would be through -an input. The required key is `secret_input` +> `v1` of this action uses the legacy `config.json` / `openfn deploy` format. +> Pin to `@v1` if your repo still uses it. -See an example project structure [here](https://github.com/OpenFn/dummy-deploy-test) - -An example of how to use this action in workflow -``` +```yaml on: push: branches: - main + workflow_dispatch: + inputs: + force: + type: boolean + default: false jobs: deploy-to-lightning: runs-on: ubuntu-latest - name: Deploy this project to OpenFn/Lightning + permissions: + contents: write steps: - - name: Deploy to Lightning - uses: openfn/deploy-action@v0.1.9 - with: + - name: openfn deploy + uses: openfn/cli-deploy-action@v2 + with: secret_input: ${{ secrets.OPENFN_API_KEY }} + project_id_input: + endpoint_input: https://app.openfn.org + force_input: ${{ inputs.force || false }} + workspace_input: projects/my-project # optional, defaults to the repo root ``` - diff --git a/action.yml b/action.yml index b7d5737..d29a7f1 100644 --- a/action.yml +++ b/action.yml @@ -2,14 +2,26 @@ name: 'openfn deploy' branding: icon: 'upload' color: 'purple' -description: 'Deploys a yaml file to a Lightning instance' +description: 'Deploys an OpenFn project workspace to a Lightning instance' inputs: secret_input: description: "OpenFN API KEY" required: true - config_path_input: - description: "OpenFN Path to Config" + project_id_input: + description: "OpenFN Project ID to deploy to" required: true + endpoint_input: + description: "Lightning URL, e.g. https://app.openfn.org. Defaults to the endpoint the workspace tracks" + required: false + default: '' + workspace_input: + description: "Folder holding the project's openfn.yaml, relative to the repo root. Defaults to the root" + required: false + default: '' + force_input: + description: "Deploy even if the project has changed in Lightning since the last sync" + required: false + default: 'false' runs: using: "composite" steps: @@ -20,13 +32,26 @@ runs: with: node-version: 24.x - run: | - npm install -g @openfn/cli - openfn deploy -c $OPENFN_CONFIG_PATH --no-confirm + npm install -g @openfn/cli@latest + + args=(--no-confirm) + if [ -n "$OPENFN_DEPLOY_ENDPOINT" ]; then + args+=(--endpoint "$OPENFN_DEPLOY_ENDPOINT") + fi + if [ "$OPENFN_FORCE" = "true" ]; then + args+=(--force) + fi + openfn project deploy "$OPENFN_PROJECT_ID" "${args[@]}" shell: bash - env: + env: OPENFN_API_KEY: ${{ inputs.secret_input }} - OPENFN_CONFIG_PATH: ${{ inputs.config_path_input }} + OPENFN_PROJECT_ID: ${{ inputs.project_id_input }} + OPENFN_DEPLOY_ENDPOINT: ${{ inputs.endpoint_input }} + OPENFN_FORCE: ${{ inputs.force_input }} + OPENFN_WORKSPACE: ${{ inputs.workspace_input }} + # Sync relies on deploy rewriting the checkout files (.openfn/) + OPENFN_NO_CHECKOUT_AFTER_DEPLOY: 'false' - name: Commit updated state file uses: stefanzweifel/git-auto-commit-action@v7 - with: + with: commit_message: Changes accepted by Lightning; updated current project state