Feeding Yontrack from GitHub Actions workflows
Note
Make sure Yontrack is configured for GitHub.
First, your GitHub workflows need to be able to connect to Yontrack.
In Yontrack, create a token.
At your repository (or organization) level, create the following elements:
- a variable named
YONTRACK_URLcontaining the URL of your Yontrack instance - a secret named
YONTRACK_TOKENcontaining the token you created in the previous step
You're now ready to start feeding information into Yontrack from your GitHub workflows.
Start by creating a .yontrack/ci.yaml file at the root of your repository:
version: v1
configuration: {}
Note
This uses a default configuration for the items created in Yontrack.
See CI Configuration for more information.
In any workflow, you can use the following step:
- name: "Yontrack configuration"
id: yontrack-config
uses: nemerosa/ontrack-github-actions-cli-config@v1.0.3
env:
YONTRACK_URL: ${{ vars.YONTRACK_URL }}
YONTRACK_TOKEN: ${{ secrets.YONTRACK_TOKEN }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Note
The ontrack-github-actions-cli-config action uses the Yontrack CLI to interact with Yontrack. The action will automatically download and configure the _latest_version of the CLI. That's why the github-token parameter is required in this case.
If you want to use a specific version of the CLI, you can use the version parameter instead of github-token:
- name: "Yontrack configuration"
id: yontrack-config
uses: nemerosa/ontrack-github-actions-cli-config@v1.0.3
env:
YONTRACK_URL: ${{ vars.YONTRACK_URL }}
YONTRACK_TOKEN: ${{ secrets.YONTRACK_TOKEN }}
with:
version: 5.0.0-beta+002
This configures a project, branch and a build in Yontrack. The rest of the steps have now access to the Yontrack CLI to interact with Yontrack.
For example, to create a simple validation for the current build:
- name: Validation
run: |
yontrack validate --validation BUILD --status PASSED
or better, with a condition on a previous step you want to validate:
- name: Some step
id: some-step # The ID is needed to identity the step
run: |
# ... some steps ...
- name: Validation
# Checking if the step has actually run at all
if: ${{ steps.some-step.outcome != '' }}
# Validation status depending on the outcome of the step
run: |
yontrack validate \
--validation some-step \
--status ${{ steps.some-step.outcome == 'success' && 'PASSED' || 'FAILED' }}