Setting up your development environment in GitHub
In this tutorial, you will learn how to set up an organization in GitHub and SonarCloud so that you and your development team can collaboratively develop DataMiner artifacts while maintaining high-quality standards. This tutorial sets up the framework to achieve the same quality standards that developers at Skyline Communications adhere to. It will also add starter workflows provided by Skyline to improve efficiency. Additionally, you will learn how to set up SonarCloud, a mandatory static analysis tool used in all GitHub workflows provided by Skyline.
If you are interested in learning how to set up CI/CD in other technologies, such as Jenkins, GitLab, Concourse, Azure DevOps, etc., check out the Setting up basic CI/CD for connectors tutorial.
Expected duration: 10 minutes.
Private versus public code
Both SonarCloud and GitHub require paid licenses to fully support private GitHub repositories.
For real-world scenarios, you will likely need at least a paid SonarCloud license to work with private GitHub repositories. A free GitHub version can still be used for private repositories, but this will slightly alter how you work with the product.
Prerequisites
Overview
- Step 1: Create a GitHub organization
- Step 2: Create a SonarCloud organization and link it with GitHub
- Step 3: Set up starter workflows for your organization
- Step 4: Adjust permissions for GITHUB_TOKEN
- Step 5: Optionally add organization-wide secrets
Step 1: Create a GitHub Organization
Follow the instructions specified in the GitHub documentation.
Step 2: Create a SonarCloud organization and link it with GitHub
Follow the instructions specified in the SonarCloud documentation.
Step 3: Set up starter workflows for your organization
Optionally, create a GitHub user specifically for bot activities, e.g. CICDOrganization.
Use a shared mailbox from your organization if possible. If this is not possible, for example because of 2FA, you can use a personal GitHub account with rights to create repositories.
Add the user to your organization and ensure they have sufficient rights to create new repositories.
Go to User Settings > Developer Settings > Personal Access Tokens to create a personal access token (classic) for your GitHub user.
Make sure the token has the following scopes:
- repo
- workflow
- admin:org/write:org
- admin:org/read:org
Tip
For more details, refer to the GitHub documentation.
Fork the Skyline-Starter-Workflows repository into your organization.
Add a new secret to the fork:
Go to the settings of your fork and select Secrets and variables > Actions.
Add a new secret called
PAT
and use the previously created personal access token as the value.
Go to the Actions tab, verify the workflow content, and enable the workflow.
Go to the workflow and trigger an initial run manually.
After this, the workflow will automatically run daily to check for upstream changes.
Step 4: Adjust permissions for GITHUB_TOKEN
Some workflows provided by Skyline will automatically create files containing the information needed when you upload an artifact to the Catalog. These files retrieve data from the GitHub UI. To create an auto-generated file, the GITHUB_TOKEN in workflows must have write permissions.
Enable this at the organization level by setting the workflow permissions to Read and write permissions.
For more information, refer to the GitHub documentation.
Note
The GITHUB_TOKEN only has access to the currently running workflow. It also does not trigger new workflow runs when used to push new files, which helps prevent endless loops of CI/CD flows.
Step 5: Optionally add organization-wide secrets
Some Skyline-provided workflows require tokens and secrets to access services like SonarCloud or the DataMiner Catalog. Instead of adding secrets to every repository, you can add them organization-wide.
Unless you have a paid GitHub subscription, these secrets will only be available for public repositories.
On your GitHub organization page, select the Settings tab.
Under Security, expand Secrets and variables and select Actions.
On the Actions secrets and variables page, add a new organization secret such as
SONAR_TOKEN
, as explained under GitHub secrets and tokens.