@@ -36,41 +36,93 @@ Click `Configure`...
36
36
5 . You'll be redirected to OpenFn. Select the repository and branch you want to
37
37
sync to, and click ` Connect Branch ` .
38
38
39
- 6 . Your GitHub connection is now set up!
40
-
41
- 7 . Synchronization is _ not_ automatic. Each time you want to sync between your
42
- project and GitHub, click ` Initiate Sync to Branch ` .
43
-
44
- ![ Initiate Sync] ( /img/lightning_gh_initate_sync.png )
45
-
46
- :::tip Sync after every major change
47
-
48
- Each time you make any significant change in your project, for example changes
49
- in a job code, make sure to hit ` Initiate Sync to Branch ` to sync your updates
50
- to GitHub.
51
-
52
- :::
39
+ 6 . Once you have created a a connection, set up ` pull ` and ` deploy ` workflows
40
+ that use openfn github actions below.
41
+ 7 . Add ` OPENFN_API_KEY ` and ` OPENFN_PROJECT_ID ` repository secrets to your
42
+ Github repo as described below.
43
+ 8 . Add a ` config.json ` file to your repository which specifies your endpoint and
44
+ paths to project spec and state files.
45
+ 9 . Click the sync to Github button to initiate a sync from Lightning to GitHub.
46
+ 10 . Push a change to your selected branch to push changes from Github to
47
+ Lightning.
48
+
49
+ #### Github Repository Secrets
50
+
51
+ The workflows that interact with the OpenFn actions will need the repository set
52
+ up with two secrets used in the github actions:
53
+
54
+ - OPENFN_API_KEY: This is your API Key as generated from Lightning and will be
55
+ needed for authentication
56
+ - OPENFN_PROJECT_ID: This is your Project ID from Lightning this will be used to
57
+ pull from the lightning instance
58
+
59
+ #### Github Repository Structure
60
+
61
+ Here you can do pretty much what you want, so long as you've got a ` config.json `
62
+ pointing to your project spec, state, and Lightning endpoint.
63
+
64
+ #### Example [ Deploy Workflow] ( https://github.com/OpenFn/demo-openhie/blob/main/.github/workflows/deploy.yml ) for GitHub
65
+
66
+ See https://docs.github.com/en/actions/quickstart#creating-your-first-workflow
67
+ for more help here.
68
+
69
+ ``` yml
70
+ on :
71
+ push :
72
+ branches :
73
+ - main
74
+
75
+ jobs :
76
+ deploy-to-lightning :
77
+ runs-on : ubuntu-latest
78
+ name : A job to deploy to Lightning
79
+ steps :
80
+ - name : openfn deploy
81
+ uses : OpenFn/cli-deploy-action@v0.1.11
82
+ with :
83
+ secret_input : ${{ secrets.OPENFN_API_KEY }}
84
+ ` ` `
85
+
86
+ #### Example [Pull Workflow](https://github.com/OpenFn/demo-openhie/blob/main/.github/workflows/pull.yml) for GitHub
87
+
88
+ See https://docs.github.com/en/actions/quickstart#creating-your-first-workflow
89
+ for more help here.
90
+
91
+ ` ` ` yml
92
+ on : [repository_dispatch]
93
+
94
+ jobs :
95
+ pull-from-lightning :
96
+ runs-on : ubuntu-latest
97
+ permissions :
98
+ contents : write
99
+ name : A job to pull changes from Lightning
100
+ steps :
101
+ - name : openfn pull and commit
102
+ uses : OpenFn/cli-pull-action@v0.7.0
103
+ with :
104
+ secret_input : ${{ secrets.OPENFN_API_KEY }}
105
+ project_id_input : ${{ secrets.OPENFN_PROJECT_ID }}
106
+ commit_message_input :
107
+ ' user ${{ github.event.client_payload.message }}'
108
+ ` ` `
109
+
110
+ The Lightning [demo instance](https://demo.openfn.org) is currently connected to
111
+ [this repo](https://github.com/OpenFn/demo-openhie/). Feel free to play around
112
+ with it.
113
+
114
+ 11. Your GitHub connection is now set up! From here, each time you want to sync
115
+ between your project and GitHub, click ` Initiate Sycn to Branch`.
53
116
54
117
# ## How It Works in a Nutshell
55
118
56
- Your whole OpenFn project can be represented as a ` project.yaml ` file. It
57
- includes all your workflow specifications, their name, job code, triggers, and
58
- so on.
119
+ Your whole OpenFn project can be represented as a project.yaml file.
59
120
60
121
Using our Command Line Interface, the [@openfn/cli](../deploy/portability.md)
61
122
you can pull a project config from OpenFn to a folder or repo on your computer,
62
- and you can deploy a change in your ` project.yaml ` file from that directory or
123
+ and you can deploy a change in your project.yaml file from that directory or
63
124
repo to OpenFn.
64
125
65
- ::: info
66
-
67
- As your ` project.yaml ` file represents your entire project, this is the file
68
- that you have to update when you want to deploy any changes to your OpenFn
69
- project. If you made a change or created a new job, for example, you have to
70
- include them in the ` project.yaml ` to deploy.
71
-
72
- :::
73
-
74
126
The `Sync to Github` feature makes use of GitHub actions to automatically deploy
75
127
(after a commit) or pull (when `Initiate Sync to Branch` button is clicked) to
76
128
keep a repository in sync with your OpenFn project.
0 commit comments