I want to track our GitHub deployments on Jira so our team could have better visibility of the work.
- Is GitHub for Atlassian installed in our space: Yes ✅
- Is the Atlassian app installed in our organization: Yes ✅
- Is the Atlassian app allowed to access our project: Yes ✅
We can see branches, commits and pull requests in our issues, so both platforms seem to be connected.
Regarding deployments, GitHub says:
By default, when a workflow job references an environment, GitHub creates a deployment object to track the deployment.
Our project deploys to two environments: "QA" and "Production", so my .jira/config.yml contains
deployments:
environmentMapping:
staging:
- "QA" # Pushes to `development` trigger a deploy to QA
production:
- "Production" # Publishing releases trigger a deploy to Production
My branch, PR and commit read as follows:
Branch: feature/setup-gh-deployments_ABC-123
Commit:
```
feat: define environments for QA and production workflows
Implements: ABC-123
```
PR title: [ABC-123] Define environments for workflows
- Does the branch show in Jira: Yes ✅
- Does the commit show in Jira: Yes ✅
- Does the pull request show in Jira: Yes ✅
GitHub displayed my deployment. Jira showed nothing.
Then I read in the Jira docs:
To add deployments to your GitHub Actions workflow, you must create a deployment action in GitHub using the action chrnorm/deployment-action@releases/v1
The GitHub for Atlassian Marketplace app only listens to deployment_status events. This means GitHub deployments will only be shown in Jira if they meet the following conditions:
Deployments are created using GitHub’s create deployment API or the chrnorm/deployment-action@releases/v1 action.
After creating a deployment, you must call the create deployment status API or the chrnorm/deployment-status@releases/v1 action at least once to update the status of the deployment.
"Ah, you're not sending status events" I thought, so I modified the workflow file to push status updates:
on:
push:
branches:
- development
jobs:
deploy:
name: Deploy to QA
runs-on: ubuntu-latest
environment: QA
steps:
- name: Get Deployment ID
id: get-deployment
uses: actions/github-script@v7
with:
script: |
const deployments = await github.rest.repos.listDeployments({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
environment: 'QA'
});
core.setOutput('deployment_id', deployments.data[0].id);
- name: Checkout
uses: actions/checkout@v2
- name: Report deployment status update
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.get-deployment.outputs.deployment_id }},
state: 'in_progress',
description: 'Running preliminary steps',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
... preliminary steps...
- name: Report deployment status update
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.get-deployment.outputs.deployment_id }},
state: 'in_progress',
description: 'Building images',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
... build, tag, push ...
- name: Report deployment status update
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.get-deployment.outputs.deployment_id }},
state: 'in_progress',
description: 'Deploying to target',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
... deploy ...
- name: Report deployment success
if: success()
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.get-deployment.outputs.deployment_id }},
state: 'success',
environment_url: '${{ vars.ENVIRONMENT_URL }}',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
- name: Report deployment failure
if: failure()
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.get-deployment.outputs.deployment_id }},
state: 'failure',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
Pushed my changes, deployment statuses are sent from the workflow and I can see them through GitHub API.
In the issue detail page, I see the commit, branch PR, but no deployments! Instead I see the following message:
Connect your deployment information
You need to be a site administrator to install apps on your Jira site. Contact your admin so they can install one of the apps below.
- Is it really necessary to manually create deployments in workflows, even when GitHub automatically creates them?
- Should I ask the site admin to reinstall the app in the space and GH organization?