Skip to content

Commit 0106422

Browse files
authored
Merge pull request #26 from coursedog/DEX-36/fix-gitbuh-jira-integrations
fix(jira-integration): Complete GitHub <> JIRA integration fixes
2 parents 6fb9810 + ed5253c commit 0106422

File tree

10 files changed

+2532
-836
lines changed

10 files changed

+2532
-836
lines changed

.env.example

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ==============================================================================
2+
# Jira Integration Environment Variables
3+
# ==============================================================================
4+
# Copy this file to .env and fill in your actual values
5+
#
6+
# Required for Jira API access
7+
JIRA_BASE_URL=https://coursedog.atlassian.net
8+
JIRA_EMAIL=your-email@domain.com
9+
JIRA_API_TOKEN=your-jira-api-token
10+
11+
# Optional: Jira project key for filtering (leave empty to search all projects)
12+
JIRA_PROJECT_KEY=
13+
14+
# ==============================================================================
15+
# GitHub Context Variables (for local testing)
16+
# ==============================================================================
17+
# These are automatically set when running in GitHub Actions
18+
# For local testing, set them manually to simulate different scenarios
19+
20+
# Git reference (branch or tag)
21+
# Examples: refs/heads/main, refs/heads/staging, refs/heads/dev
22+
GITHUB_REF=refs/heads/staging
23+
24+
# Event type that triggered the workflow
25+
# Options: push, pull_request, pull_request_target
26+
GITHUB_EVENT_NAME=push
27+
28+
# Path to the GitHub event payload file
29+
# For local testing, use ./update_jira/event.local.json
30+
GITHUB_EVENT_PATH=./update_jira/event.local.json
31+
32+
# Repository in owner/repo format
33+
GITHUB_REPOSITORY=coursedog/notion-scripts
34+
35+
# GitHub token for API access (required for fetching commit data)
36+
GITHUB_TOKEN=your-github-token
37+
38+
# ==============================================================================
39+
# Testing Variables
40+
# ==============================================================================
41+
# For running verification and test scripts
42+
43+
# Test issue key for custom field verification
44+
TEST_JIRA_ISSUE_KEY=DEX-36
45+
46+
# Enable dry-run mode (will log actions but not actually update Jira)
47+
# DRY_RUN=true
48+
49+
# ==============================================================================
50+
# Custom Field Configuration Reference
51+
# ==============================================================================
52+
# The following custom fields are used for deployment tracking (from ALL-593):
53+
#
54+
# customfield_11473: Release Environment (select field)
55+
# - Option ID 11942: staging
56+
# - Option ID 11943: production
57+
#
58+
# customfield_11474: Stage Release Timestamp (datetime)
59+
# - Set automatically on staging deployments
60+
#
61+
# customfield_11475: Production Release Timestamp (datetime)
62+
# - Set automatically on production deployments
63+
#
64+
# To verify these field IDs are correct for your Jira instance:
65+
# node utils/verify-custom-fields.js
66+
#
67+
# To test updating these fields:
68+
# node utils/test-custom-field-update.js DEX-36

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module.exports = {
1010
},
1111
globals: {
1212
process: 'readonly',
13+
Buffer: 'readonly',
14+
structuredClone: 'readonly',
1315
},
1416
rules: {
1517
'no-extend-native': [ 'error', { exceptions: [ 'Array' ] } ],

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ web_modules/
7373
.yarn-integrity
7474

7575
# dotenv environment variables file
76+
.env
7677
.env.development.local
7778
.env.test.local
7879
.env.production.local

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1-
# notion-scripts
1+
# GitHub Actions for Jira Integration
2+
3+
This repository contains GitHub Actions for automating Jira issue management based on GitHub events.
4+
5+
## Actions
6+
7+
### update_jira
8+
9+
Automatically updates Jira issues based on pull request events and deployments.
10+
11+
**Features:**
12+
13+
- Transitions Jira issues based on PR status and target branch
14+
- Updates deployment metadata (environment, timestamps) for staging/production releases
15+
- Supports dry-run mode for testing
16+
- Handles multiple Jira issues in PR titles/descriptions
17+
18+
**Configuration:**
19+
20+
```yaml
21+
- uses: ./update_jira
22+
with:
23+
jira-base-url: ${{ secrets.JIRA_BASE_URL }}
24+
jira-email: ${{ secrets.JIRA_EMAIL }}
25+
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
dry-run: 'false'
28+
```
29+
30+
**Custom Fields:**
31+
32+
- `customfield_11473`: Release Environment (staging/production)
33+
- `customfield_11474`: Stage Release Timestamp
34+
- `customfield_11475`: Production Release Timestamp
35+
36+
**Local Testing:**
37+
38+
1. Copy `.env.example` to `.env` and fill in credentials
39+
2. Create `update_jira/event.local.json` with a sample GitHub event
40+
3. Run: `node update_jira/index.js`
41+
42+
**Verification Scripts:**
43+
44+
- `utils/verify-custom-fields.js`: Verify custom field IDs exist in your Jira instance
45+
- `utils/test-custom-field-update.js`: Test custom field updates with rollback
46+
47+
**Integration Tests:**
48+
49+
Run comprehensive Jira API integration tests:
50+
51+
```bash
52+
node utils/jira.integration.test.js
53+
```
54+
55+
This test suite will:
56+
57+
- Test all Jira utility methods (workflows, transitions, custom fields, etc.)
58+
- Capture the original state of your test issue before making changes
59+
- Perform real API calls to your Jira instance
60+
- Prompt you to rollback all changes at the end
61+
62+
**Required environment variables:**
63+
64+
- `JIRA_BASE_URL`, `JIRA_EMAIL`, `JIRA_API_TOKEN` (required)
65+
- `TEST_JIRA_ISSUE_KEY` (default: `DEX-36`)
66+
- `TEST_JIRA_PROJECT_KEY` (default: `DEX`)
67+
- `TEST_JIRA_CUSTOM_FIELD` (default: `customfield_10001`)
68+
- `TEST_JIRA_CUSTOM_VALUE` (default: `test-value`)
69+
- `TEST_JIRA_STATUS` (default: `Done`)
70+
- `TEST_JIRA_PR_URL` (optional)
71+
72+
Add these to your `.env` file before running the test.
73+
74+
## Development
75+
76+
**Prerequisites:**
77+
78+
- Node.js 16+
79+
- Jira account with API token
80+
- GitHub repository access
81+
82+
**Installation:**
83+
84+
```bash
85+
npm install
86+
```
87+
88+
**Environment Variables:**
89+
90+
See `.env.example` for required configuration.
91+
92+
## Related Tickets
93+
94+
- **DEX-36**: Fix GitHub <> JIRA integration malfunctions
95+
- **ALL-593**: Push deployment metadata to Jira custom fields

0 commit comments

Comments
 (0)