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.
...
Code Block |
---|
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
.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
Step 2: Save the Workflow
...