You’ve already created a GitHub repository and maybe have some initial commits but are now wanting to share this with members of your team or the greater GitHub community.
You’d like a level of confidence that the code that’s merged into the main branch is consumable without having to fix build errors. Of course, this process will not guard against logic errors, but this article will also document requiring pull requests (PRs) so that at least one other developer is reviewing commits before merging changes into main.
The screenshots in this document are from our fhir-link repository. Fhir-link (pronounced “fire link”) is a .net Core 6.0 Azure function that performs an integration between an FHIR Service and Dynamics 365 Customer Insights. You can find the actual code in the repository there. Good documentation from GitHub is also contained in the GitHub Marketplace and GitHub Docs.
The steps below reference the callouts in the editor screen shot. Base your work off of the fhir-link example or the code within the GitHub example.
Figure 1: Visual Studio screenshot of yaml file
Ubuntu was chosen since it already has the latest .net core libraries which allows it to run more quickly. “windows-latest” is also an option here.
This reference’s GitHub’s repository, hence it is GitHub’s nomenclature: “actions/checkout@master” instead of “actions/checkout@main” - this repo’s nomenclature
Ready the .NET core environment to be used in the build.
Pull the code from the GitHub repo to the working directory.
Compile the code in the working directory using the Release build configuration
Inspect the assemblies and run any test methods found.
Once saved in .github\workflows, the action will run automatically when the “on” event occurs – in this case, the pull request. But there’s nothing forcing a PR to wait for it to complete successfully. To fix this we need to configure a GitHub branch protection rule.
Figure 2: GitHub steps to add a branch protection rule
Figure 3: Branch protection setting detail
Other best practice settings for your main development branch include
Create a PR, you should see the checks initially in yellow, then turn green when complete (assuming success).
Figure 4: Pull Request view while checks are running |
Figure 5: Pull Request view after checks have completed |
You may have some reusable components in this repository. If so, this action should also package and publish to your package repository. For more detail, see Publishing to package registries in the GitHub Docs.
Depending on your deployment target (Kubernetes, an app service, a function app, etc) in addition to CI, you may also want to configure Continuous Deployment (CD) in your GitHub repository. The concepts are similar. You can see the sample yaml file from our fhir-link repository here, or see detailed documentation in the GitHub Docs.
This was a good review of GitHub actions and branch security. I hope you found value in this write up.
If you’d like to be part of a community of healthcare developers sharing knowledge and resources, check out our HLS Developer discord at https://aka.ms/HLS-Discord. We have links to all our content there and a bunch of channels to communicate with us and likeminded tech and healthcare people.
Hope to see you there!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.