GitHub (GitHub as master)
This is step-by-step guide for setting up a GitHub Actions pipeline to synchronize modified .feature
files from a GitHub repository to the AssertThat plugin. This guide ensures that only modified feature files from the commit on which the pipeline is triggered are uploaded to AssertThat.
Prerequisites:
Access to GitHub and a GitHub repository.
Access to your Jira instance with the admin permissions to projects.
Your AssertThat project's
ASSERTTHAT_ACCESS_KEY
andASSERTTHAT_SECRET_KEY
, which can be obtained from the AssertThat project configuration.Your AssertThat project's
PROJECT_ID
, which you can obtain from AssertThat.
Step 1: Create a GitHub Actions Workflow
1.1. Go to your GitHub repository and navigate to the "Actions" tab.
1.2. Click on the "Set up a workflow yourself" option to create a custom GitHub Actions workflow.
1.3. In the code editor, define your workflow file (e.g., .github/workflows/feature_sync.yml
) with the following contents:
name: Feature Sync to AssertThat
on:
push:
branches:
- main # Trigger the workflow when changes are pushed to the main branch
jobs:
sync_features:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install curl
run: sudo apt-get install curl
- name: Upload Modified Feature Files to AssertThat
run: |
# Set up Git with your GitHub repository credentials
# Replace the following placeholders with actual values:
# - YOUR_ASSERTTHAT_ACCESS_KEY
# - YOUR_ASSERTTHAT_SECRET_KEY
# - YOUR_JIRA_HOST (AssertThat API endpoint, typically the Jira host)
# - YOUR_ASSERTTHAT_PROJECT_ID (the ID of your project in AssertThat)
# Get the list of modified .feature files in the commit
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.feature$' > modified_features.txt
# Iterate through the modified .feature files and upload each one
while IFS= read -r file; do
curl -X POST \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Basic $(echo -n YOUR_ASSERTTHAT_ACCESS_KEY:YOUR_ASSERTTHAT_SECRET_KEY | base64)" \
-F "file=@$file" https://YOUR_JIRA_HOST/rest/assertthat/latest/project/YOUR_ASSERTTHAT_PROJECT_ID/client/upload?override=true
# NOTE: The example above is for Jira Data Center. In case you use cloud version the following URL should be used for uploading features: https://bdd.assertthat.app/rest/api/1/project/YOUR_ASSERTTHAT_PROJECT_ID/feature?override=true
done
env:
YOUR_ASSERTTHAT_ACCESS_KEY: ${{ secrets.YOUR_ASSERTTHAT_ACCESS_KEY }}
YOUR_ASSERTTHAT_SECRET_KEY: ${{ secrets.YOUR_ASSERTTHAT_SECRET_KEY }}
YOUR_JIRA_HOST: https://your-jira-host
YOUR_ASSERTTHAT_PROJECT_ID: your-assertthat-project-id
Replace the placeholders with your specific GitHub repository details, AssertThat access key, AssertThat secret key, AssertThat API endpoint, and the project ID from AssertThat.
Ensure that you have created GitHub secrets for
YOUR_ASSERTTHAT_ACCESS_KEY
andYOUR_ASSERTTHAT_SECRET_KEY
.
Step 2: Save the Workflow
Commit and push the workflow file to your GitHub repository.
Step 3: Trigger the Workflow
The workflow will be triggered automatically when changes are pushed to the main branch. You can also manually trigger the workflow from the Actions tab of your GitHub repository.
With this GitHub Actions pipeline in place, it will identify the modified .feature
files in the commit on which the pipeline is triggered and upload them to AssertThat, ensuring the synchronization of modified feature files.