Skip to content

Commit

Permalink
Merge pull request #432 from OpenFn/gh_sync_update
Browse files Browse the repository at this point in the history
Gh sync update
  • Loading branch information
aleksa-krolls authored Mar 14, 2024
2 parents 34eddf5 + d5fb6f0 commit 7575fa1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
81 changes: 48 additions & 33 deletions docs/manage-projects/link-to-gh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ slug: /link-to-Github
You can set up version control for your OpenFn projects. This article walks you
through the configuration steps.

### How It Works in a Nutshell

Your whole OpenFn project can be represented as a `project.yaml` file.

The `Sync to Github` feature makes use of Github actions to automatically deploy
(after a commit) or pull (when `Initiate Sync to Branch` button is clicked) to
keep a repository in sync with your OpenFn project.

Using our Command Line Interface, the [@openfn/cli](../deploy/portability.md)
you can pull a project config from OpenFn to a folder or repo on your computer,
and you can deploy a change in your `project.yaml` file from that directory or
repo to OpenFn.

For more detailed information on representing your project as code and using the
@openfn/cli, head over to our documentation on
[Portability](../deploy/portability.md).

### Setting Up Github Integration

You can connect your OpenFn project to a Github repository that you have
Expand Down Expand Up @@ -53,24 +36,32 @@ Click `Configure`...
5. You'll be redirected to OpenFn. Select the repository and branch you want to
sync to.
6. The Github sync process makes use of `pull` and `deploy` Github actions to
sync between your OpenFn project and Github repo (more on this under
`How it works` below.) In order to do this, a `pull.yml` and a `deploy.yml`
file will be committed to your chosen repository when you proceed to connect
your branch. If you have files with these names in your repo, they will be
overwritten.
sync between your OpenFn project and Github repo (more on these in the
`How it works` section below). In order to do this, a `pull.yml` and a
`deploy.yml` file will be committed to your chosen repository when you
proceed to connect your branch. If you have files with these names in your
repo, they will be overwritten.
7. Click `Connect Branch`.
8. Add `OPENFN_API_KEY` and `OPENFN_PROJECT_ID` repository secrets to your
Github repo as described below.

#### Github Repository Secrets

The workflows that interact with the OpenFn actions will need the repository set
up with two secrets used in the github actions:
up with two secrets used in the Github actions. On your Github repo, go to
`Settings` in the top menu. Then on the left, under `Security`, expand the
`Secrets and variables` menu and choose `Actions`. Then click the
`New repository secret` button to add the two below secrets.

- OPENFN_API_KEY: This is your API Key as generated from OpenFn and will be
needed for authentication
- OPENFN_PROJECT_ID: This is your Project ID from OpenFn this will be used to
pull from the OpenFn instance
![Secrets](/img/lightning_add_repo_secrets.png)

- OPENFN_API_KEY: This is your [API Key](../manage-users/api-tokens.md)] as
generated from OpenFn and will be needed for authentication
- OPENFN_PROJECT_ID: This is your Project ID from OpenFn. You can copy it from
the address bar on your browser, selecting the part after
`https://app.openfn.org/projects`, it will look something like this:
`4b31f7td-1130-421p-al39-g8n17doddac7`. It will be used to pull from the
OpenFn instance.

9. Add a `config.json` file as below to your repository which specifies your
endpoint and paths to project spec and state files. Both of these files will
Expand All @@ -85,8 +76,15 @@ up with two secrets used in the github actions:
```

10. Click the sync to Github button to initiate a sync from OpenFn to GitHub.
11. Push a change to your selected branch to push changes from Github to OpenFn.
12. Your GitHub connection is now set up!
Once it's done, you'll see the new `projectState.json` and `project.yaml`
files appear on your repo.
11. Your GitHub connection is now set up!

:::info

Make sure you link one Github branch to only one OpenFn project.

:::

#### Using Version Control

Expand All @@ -100,10 +98,10 @@ representation of your project as code.
##### Github to OpenFn

Any time there are changes made to that branch in your Github repo, those
changes will be pushed to your OpenFn project via `openfn deploy`. Note that as
your entire project is represented in your `project.yaml` file, you have to add
all your changes to this file in order for them to be deployed to your OpenFn
project when syncing.
changes will be pushed to your OpenFn project. Note that your entire project is
represented in your `project.yaml` file. In order to deploy any changes to
OpenFn, you have to add them to this file in order for them to be deployed when
syncing.

#### Github Repository Structure

Expand All @@ -113,3 +111,20 @@ pointing to your project spec, state, and OpenFn endpoint.
The OpenFn v2 (Lightning) [demo instance](https://demo.openfn.org) is currently
connected to [this repo](https://Github.com/OpenFn/demo-openhie/). Feel free to
play around with it.

### How It Works in a Nutshell

Your whole OpenFn project can be represented as a `project.yaml` file.

The `Sync to Github` feature makes use of Github actions to automatically deploy
(after a commit) or pull (when `Initiate Sync to Branch` button is clicked) to
keep a repository in sync with your OpenFn project.

Using our Command Line Interface, the [@openfn/cli](../deploy/portability.md)
you can pull a project config from OpenFn to a folder or repo on your computer,
and you can deploy a change in your `project.yaml` file from that directory or
repo to OpenFn.

For more detailed information on representing your project as code and using the
@openfn/cli, head over to our documentation on
[Portability](../deploy/portability.md).
2 changes: 1 addition & 1 deletion sidebars-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
'build-for-developers/cli-usage',
'build-for-developers/cli-walkthrough',
'build-for-developers/cli-challenges',
'build-for-developers/jobs',
// 'build-for-developers/jobs',
'build-for-developers/build-with-api',
'build-for-developers/security-for-devs',
],
Expand Down
Binary file added static/img/lightning_add_repo_secrets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7575fa1

Please sign in to comment.