KB Workflow
Steps for making changes
Step 1 - Login to your Product Factory workload account
These steps should have been followed here.
Once you have followed this, you should be able to login to AWS via typing login-pf
.
Step 2 - Ensure you are are up to date
Make sure you are up to date with the most recent changes in the repository before you start making any changes.
You can do this with:
git pull -ff
- -ff: means fast forward, we are doing a fast forward pull. We can also clean up remote branches that may not be there anymore:
git fetch -p
- -p: means prune, we are pruning what we fetch. Getting rid of stuff that doesn't exist anymore.
Step 3 - Make a branch for your work
Next we want to create a branch for our work.
Name your branch something relevant to what you are doing (e.g bookclub notes)
The below commands create a branch and then move us to that branch.
git branch <branch-name>
git checkout <branch-name>
Or alternatively we can do this in one command.
This command moves to a branch and if this branch doesn't exist (which in our case it won't) creates it and moves us to it:
git checkout -b <branch-name>
Step 4 - Begin work
Now that we are on our branch we can begin working!
Keep your work limited to one thing (what you named the branch).
Once you have completed this task you set out to do, we can move on.
This step includes running your work locally to ensure you are happy with it.
You can do this via the following command:
npm run dev
Step 5 - Make sure you are up to date
The work is done and we are ready to move forward.
However, while we were working, someone else may have made changes.
So let's check and if there are any lets get them.
git pull -ff
Keep in mind, you may need to login-pf
again if your session timed out
Step 6 - Push changes to remote AWS repo
We can now push our changes up to the remote repository in AWS
git push origin <branch-name>
Step 7 - Create a Pull Request (PR)
Now we want to go into AWS -> pf-workloads -> Management console -> Search in the search bar "CodeCommit" -> graduate-programme-kb-v2 -> Create Pull Request
TIP: You can favourite CodeCommit by pressing the star next to it when you search it. This will avoid you having to type it everytime.
Once you have found the button to create your pull request, you want the destination branch to be where you want it to go which in this case will be master 99% of the time.
Then your branch is the source branch.
Then you want to press "Compare"
You will want to review the changes your self on AWS to be sure they're okay.
NOTE: If you find a mistake don't stress, all you need to do is make the change back in your editor, commit it and push it (ON YOUR BRANCH).
Then back in your PR just refresh the page. Your PR is linked to your branch and hasn't actually been made yet, so it should just update with the new changes.
Once you are happy, PRESS Create Pull Request and send the link in your URL to your peers for a peer review.
Once it has been peer reviewed you want to send this link to Rami (or whoever it is that's looking after you)
NOTE: Same principle as before, if there is an error and you need to change it. Just go back to the editor and change it. This PR is linked directly to your branch.
Which still exists (more on this soon) so there are no issues making the change, committing it and pushing it.
Step 8 - Merge your PR
Once you have the all clear with your PR, you can go back into the PR on AWS and merge it.
You want to do a Fast Forward Merge nothing else. If you can't do a fast forward merge, something is wrong which we will cover later on.
When we do this step make sure to tick the box that asks if you want to delete the branch after merging.
Step 9 - Deploying Changes to Production
Once you merge the PR to master you want to:
- checkout master
git checkout master
- pull latest changes
git pull -ff
- Install latest packages
npm i
- deploy the latest KB to production
npm run deploy
Troubleshooting
If you can't Fast Forward Merge
If you can't fast forward merge, your branch has most likely diverged.
You can check your current situation with
git log
To do a rebase we want to be on your branch
git checkout <branch-name>
Then we want to rebase with master:
git rebase -f master
This essentially re-bases our branch on top of the master branch by copying our commits on top of master and then it moves master to the most recent commit.
This is what a Fast Forward Rebase is.
For thinking purposes think of rebasing as setting your target (master) as the floor and stacking your branch on on top of it.
You then want to push these changes with
git push
This should then allow you to do a fast forward merge