name: Release Pipeline with Docket QA
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_to_qa:
description: 'Git tag to run QA against (e.g., v1.0.0). Must exist.'
required: true
type: string
jobs:
initiate_docket_qa:
name: Initiate Docket QA Tests
runs-on: ubuntu-latest
permissions:
contents: read # To checkout the code/tag
statuses: write # To set the initial "pending" commit status
steps:
- name: Determine Ref and SHA for QA
id: qa_commit_details
run: |
REF_TO_CHECKOUT=""
SHA_FOR_STATUS="" # Will be determined after checkout for workflow_dispatch
TAG_NAME=""
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG_NAME="${{ github.ref_name }}"
REF_TO_CHECKOUT="refs/tags/$TAG_NAME"
SHA_FOR_STATUS="${{ github.sha }}" # For release events, github.sha is the commit SHA of the tag
echo "Release event for tag: $TAG_NAME, Ref: $REF_TO_CHECKOUT, SHA: $SHA_FOR_STATUS"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG_NAME="${{ github.event.inputs.tag_to_qa }}"
REF_TO_CHECKOUT="refs/tags/$TAG_NAME"
echo "Workflow dispatch for tag: $TAG_NAME, Ref: $REF_TO_CHECKOUT. SHA will be resolved after checkout."
# SHA_FOR_STATUS will be set in the next step after checkout
else
echo "::error::Unsupported event: ${{ github.event_name }}"
exit 1
fi
echo "ref_to_checkout=${REF_TO_CHECKOUT}" >> $GITHUB_OUTPUT
echo "sha_for_status_initial=${SHA_FOR_STATUS}" >> $GITHUB_OUTPUT
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
- name: Checkout Code for QA
uses: actions/checkout@v4
with:
ref: ${{ steps.qa_commit_details.outputs.ref_to_checkout }}
fetch-depth: 0 # Ensure tags are fetched
- name: Resolve SHA for Tag (if not already set)
id: resolve_sha
run: |
FINAL_SHA="${{ steps.qa_commit_details.outputs.sha_for_status_initial }}"
if [ -z "$FINAL_SHA" ]; then
# This path is mainly for workflow_dispatch, where SHA is resolved from the checked-out ref
echo "Resolving SHA from checked-out ref: ${{ steps.qa_commit_details.outputs.ref_to_checkout }}"
FINAL_SHA=$(git rev-parse HEAD)
if [ -z "$FINAL_SHA" ]; then
echo "::error::Could not resolve SHA for ref ${{ steps.qa_commit_details.outputs.ref_to_checkout }} after checkout."
exit 1
fi
echo "Resolved SHA: $FINAL_SHA"
fi
echo "sha_for_status=${FINAL_SHA}" >> $GITHUB_OUTPUT
- name: Set Initial QA Status to Pending
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const releaseTag = "${{ steps.qa_commit_details.outputs.tag_name }}";
const sha = "${{ steps.resolve_sha.outputs.sha_for_status }}";
if (!sha) {
core.setFailed("Could not determine commit SHA to set status.");
return;
}
core.info(`Setting 'pending' status for Docket QA on tag: ${releaseTag} (SHA: ${sha})`);
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: sha,
state: 'pending',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, // Link to this workflow run
description: 'Docket QA tests initiated, awaiting results...',
context: 'ci/docket-qa' // Must match the context used by the listener and deploy workflow
});
core.info("Pending status set successfully.");
- name: Trigger Docket QA Test
id: trigger_docket_qa
uses: signdocket/docket-action@v2 # Assuming this action uses the GITHUB_SHA of the checked-out commit
with:
apiKey: ${{ secrets.DOCKET_API_KEY }}
repositoryFullName: ${{ github.repository }}
# The docket-action should pick up the correct commit SHA after the checkout step.
# Ensure the docket_run_completed event payload contains this SHA as 'commitSha'.
testParameters: |
{
"test_blueprint_category_id": "3",
"test_suite_url_overrides": {
"3": "https://bing.com"
},
"test_url_overrides": {
"15": "https://staging.docketqa.com"
}
}
- name: QA Process Initiated
run: |
echo "Docket QA test process has been initiated for release tag: ${{ steps.qa_commit_details.outputs.tag_name }} (SHA: ${{ steps.resolve_sha.outputs.sha_for_status }})."
echo "Docket run ID: ${{ steps.trigger_docket_qa.outputs.runId }}"
echo "Awaiting webhook from Docket server to update commit status via the 'Docket Run Results' workflow."