Skip to content

Commit c494024

Browse files
author
Daniel Rosenberg
committedApr 24, 2022
Added guidance migrated from old action README files
1 parent 3d317b1 commit c494024

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

‎README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ This is a template repository, and you'll need to create a new repository (using
2525

2626
### 1. Set the required secrets
2727

28-
You'll need to set some values before you can run the actions in this repository.
28+
You'll need to set some values before you can run the workflows in this repository.
2929

3030
Go to **Settings > Secrets** and add the following secrets:
3131

3232
| Name | Value |
3333
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
34-
| `ORGFLOW_LICENSEKEY` | Your OrgFlow license key (you can get one at https://www.orgflow.io/trial if you do not already have one) |
34+
| `ORGFLOW_LICENSEKEY` | Your OrgFlow license key (you can get one at https://www.orgflow.io/trial if you do not already have one) |
3535
| `ORGFLOW_STACKNAME` | The name of the stack that you'd like to create (e.g. `MyStack`) |
3636
| `SALESFORCE_USERNAME` | Your Salesforce production username |
3737
| `SALESFORCE_PASSWORD` | Your Salesforce production password (remember to [add your security token to the end of your password](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_concepts_security.htm) if needed) |
@@ -90,7 +90,7 @@ Go to the **Actions** tab again, and run the workflow named **Flow out an enviro
9090

9191
Note that although we manually triggered this workflow, it would also be possible to use the standard `push` GitHub Action trigger to watch for changes to the branch and run this workflow whenever changes are pushed to the branch.
9292

93-
Wait for that action to complete, and then log into the `OFUAT` sandbox - you'll see that the `Car` object is now in this sandbox too.
93+
Wait for that workflow to complete, and then log into the `OFUAT` sandbox - you'll see that the `Car` object is now in this sandbox too.
9494

9595
### 6. Advanced merging
9696

@@ -102,14 +102,31 @@ Log into your `OFQA` sandbox and edit the label of the `Car` object. Change it t
102102

103103
> TIP: If you're feeling adventurous, you can edit the label in **both** sandboxes - you'll end up with a _merge conflict_. OrgFlow fully embraces the occurrence of merge conflicts, and you can simply use standard Git conflict resolution techniques to resolve them, but that's beyond the scope of this basic guide.
104104
105-
Now that we've made your changes, we need to get them into Git. Go to the **Actions** tab, and there's an action named **Flow in all environments**. This action has been set up to run on a schedule every night at 1 am, but why wait until then? Click the **Run workflow** drop-down, then click the green **Run workflow** button to manually trigger this workflow.
105+
Now that we've made your changes, we need to get them into Git. Go to the **Actions** tab, and there's a workflow named **Flow in all environments**. This workflow has been set up to run on a schedule every night at 1 am, but why wait until then? Click the **Run workflow** drop-down, then click the green **Run workflow** button to manually trigger this workflow.
106106

107-
In a previous step, we used a similar (but different) action to flow in the changes from a **single** environment. This action queries OrgFlow for a list of all environments, and then will flow each one in. If you've been following this guide, then that's three environments in total (`Production`, `QA`, and `UAT`).
107+
In a previous step, we used a similar (but different) workflow to flow in the changes from a **single** environment. This workflow queries OrgFlow for a list of all environments, and then will flow each one in. If you've been following this guide, then that's three environments in total (`Production`, `QA`, and `UAT`).
108108

109-
Once that action has completed, create another pull request to merge the changes from the branch `sandbox/qa` into `sandbox/uat`. You'll notice that the changes can be merged, so press the **Merge** button, and wait for the automatic deployment action to trigger again. Once that action is complete, you'll notice that the `Car` object in the sandbox `OFUAT` has been updated with the changes from the other sandbox, and that the changes already in `OFUAT` were retained too.
109+
Once that workflow has completed, create another pull request to merge the changes from the branch `sandbox/qa` into `sandbox/uat`. You'll notice that the changes can be merged, so press the **Merge** button, and wait for the automatic deployment workflow to trigger again. Once that workflow run is complete, you'll notice that the `Car` object in the sandbox `OFUAT` has been updated with the changes from the other sandbox, and that the changes already in `OFUAT` were retained too.
110110

111111
If you'd like to merge the changes back into the `OFQA` sandbox, then you simply need to create and merge another pull request (this time from the branch `sandbox/uat` into `sandbox/qa`), and then run the **Flow out an environment** workflow.
112112

113+
## Enumerating environments
114+
115+
The **Flow in all environments** workflow shows an example of enumerating environments in your stack and performing some work (in this case an inbound flow) for a subset of them in parallel using a GitHub Actions matrix job in your workflow.
116+
117+
You may have other jobs that you want to run against multiple environments only known at runtime. You can take advantage of the `env:list` command to retrieve all of the environment names in a stack and use a matrix strategy to run a job once for each environment.
118+
119+
The trick here is to use a tool called [jq](https://stedolan.github.io/jq/) to transform the output from `env:list` into the format that GitHub Actions expects for a matrix definition. The correct jq syntax for this is `[.[] | .name]`. On top of this, `jq` offers a robust filtering syntax, for example if you only want to run your job on environments matching certain criteria.
120+
121+
`jq` is pre-installed on GitHub-hosted runners, and it is also pre-installed in the official OrgFlow CLI Docker image.
122+
123+
Here are some examples of useful `jq` commands you can apply on the output of `env:list`:
124+
125+
- Get an environment by name: `jq '[.[] | select(.name == "myEnvironmentName")] | select(. | length > 0)[0]' -c`
126+
- Get an environment by Git branch: `jq '[.[] | select(.git.branch == "myGitBranch")] | select(. | length > 0)[0]' -c`
127+
- Get the name of the production environment: `jq '[.[] | select(.org.production == true) | .name] | select(. | length > 0)[0]' -c`
128+
- Get the names of all the environments and transform them into a format that GitHub Actions will accept as a matrix: `jq '[.[] | .name]' -c`
129+
113130
## Next steps
114131

115132
This guide was simply an introduction to how some of the most fundamental operations of OrgFlow can be integrated into GitHub Actions.

0 commit comments

Comments
 (0)
Please sign in to comment.