How to use GitActions with Digibee Platform
⭐️ The main benefit of this article for businesses is the Digibee platform’s ability to integrate seamlessly into their CI/CD processes. This addresses a common concern among companies with robust governance and change management processes.
This article shows how to enable the Digibee Platform to integrate into companies’ change management processes. In this article the example of tools used are github and gitActions, but keep in mind that this content is an example and can be adjusted to your needs and integrate with other similar tools.
Summary
Introduction
Repository
Create GitHub Repository
Setup Action Secrets
GitActions permissions
Setup workflow on project
Commit & test
Developer use
Introduction
This step-by-step guide will show you how to set up a workflow using GitHub Actions to automatically commit the flowspec of the pipeline, approve the merge request flow, and deploy the pipeline.
Pre requisites:
- Basic knowledge of git
- Basic knowledge of the change management process
- GitHub account
- Git cli https://git-scm.com/ installed
- GitHub cli https://github.com/cli/cli#installation installed
- GitHub authenticated: https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git#github-cli
- Username and password configured:
git config user.email youremail@mail.com
git config user.name "Your name"
- Optional: VSCode installed, as well as the Github Actions Plugin, or Github Dev. These tools will assist you in customizing the YAML workflow.
- Digibeectl token file, passphrase and key. If you don’t know how to get this. Check this article from Artur Scheiner or digibee docs
Create github repository
Go to github.com/new and create a new repository to sync with your pipeline.
Setup Actions Secrets
Go to your project settings and create the following secrets.
- KEY: The auto-generated secret key that you receive when you obtain your digibeectl token.
- PASS: The passphrase that you used to obtain the digibeectl token.
- TOKEN: The content of the digibeectl token file.
- ⚠️ Important: The contents of the token must be escaped. Add
\
before{ }
and"
GitActions permissions
Make sure that the workflow has access to read and write the repository.
To do this, go to “Settings > Actions > General” and select Read and write permissions.
Setup workflow on project
It’s up to you to follow the next steps using command line, VS Code, or others tools from your preference.
- Clone repository and create new branch
git clone <https://github.com/....../.......git>
cd {{your-repository}}
git checkout -b features/pipeline-workflow
- Create folder: .github/workflow
mkdir .github
cd .github
mkdir workflows
- Create the files below following the examples provided.
./metadata.json
./.github/workflows/commit-flow-spec.yml
./.github/workflows/deploy-pipeline.yml
- metadata.json
{
"pipelineName": "your-pipeline-name",
"majorVersion": "1"
}
- commit-flowspec.yml
- deploy-pipeline.yml
Please copy the latest example from my GitHub.
<https://github.com/vchrist1/digibee-pe-hello-world-pipeline/blob/main/.github/workflows/commit-flowspec.yml>
<https://github.com/vchrist1/digibee-pe-hello-world-pipeline/blob/main/.github/workflows/deploy-pipeline.yml>
Commit & test
Now you are ready to test the workflow.
Let’s commit the changes to the features/pipeline-workflow branch.
# check if you are in the expected branch, we are using other branch to test both of the flows.
git branch
git add .
# check the files to be commited
git status
# Changes to be committed:
# (use "git restore --staged <file>..." to unstage)
# new file: .github/workflows/commit-flowspec.yml
# new file: .github/workflows/deploy-pipeline.yml
# new file: metadata.json
git commit -m "teste workflow"
git push
Go to the GitHub page and click on GitHub Actions. Check that your actions are executed without errors.
Let’s test the next Actions that will deploy the pipeline. To do this, create a pull request for the main branch and merge it.
Developer use
To start flowspec’s automatic commit process, you can simply create a new commit. There is no need to make changes to the project files.
git checkout main
git pull
git checkout -b features/example-new-branch
git commit -m "testando fluxo" --allow-empty
git push
Changes to the pipeline will be automatically committed using digibeectl through Git Actions, and you can see these changes in flowspec.json
The next step is to review the changes and promote a branch to your main branch, and then the pipeline will be deployed.