Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH staging/prod project #577

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/manage-projects/staging-prod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Version Control for Staging and Production Projects
sidebar_label: Version Control for Staging and Production Projects
slug: /staging-prod
---

It's a safe and efficient practice to use separate production and staging/testing projects to build out and test your workflows before starting to use them in production. This can be made seamless using Version Control. This guide walks you through how to set up your OpenFn projects and GitHub repo and gives you an example of how to manage your Staging > Production workflow.

1. First, create a Production and a Staging project on OpenFn

![Prod and Staging Projects](/img/openfn_prod_staging.png)

2. Choose/create a GitHub repo for your project, and create a staging branch

![Prod and Main Branches](/img/staging_prod_branches_gh.png)

3. Connect your projects to the main and staging respectively - use [this guide](../manage-projects/link-to-gh.md) to set up the connection
4. In each repo, create an empty .js file for your job. Make sure they have the same name and path on each repo (e.g. `upsert-contacts.js`). These will store the code for the job they'll be linked to in the next step.

5. When you connected the branches to your projects in step 3 above, there was a `spec.yaml` file automatically created on the branch after the first sync (along with two other configuration files). Open these files on GitHub, and locate your job in the file. Replace the contents of `body` with: `path: {path to the related js file}`. Do this on both your `main` and `staging` branches.

![Spec Main](/img/path_main.png)
![Spec Staging](/img/path_staging.png)

6. You're now all set up!
7. To sync a change from your staging project to production, go to your staging project on OpenFn and make edits to your job.
8. Then go to Settings > Synch to GitHub, and click Initiate Sync to Branch
9. Head over to GitHub. On your staging branch you'll see an update that there have been recent changes. Click `Compare & pull request`

![Create Pull Request](/img/staging_pushes.png)

10. Create a Pull Request. This will automatically include all changes that happened to the files on the staging branch.

![Save Pull Request](/img/create_pr.png)


11. According to your team workflow, have someone to approve and merge the Pull Request, or click `Merge pull request`.

12. Your changes will now be automatically deployed to your OpenFn prod project.
1 change: 1 addition & 0 deletions sidebars-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ module.exports = {
'manage-projects/workflow-dashboard',
'manage-projects/collaboration',
'manage-projects/oauth',
'manage-projects/staging-prod',
],
},
{
Expand Down
Binary file added static/img/create_pr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/openfn_prod_staging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/path_main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/path_staging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/staging_prod_branches_gh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/staging_pushes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.