Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update git-issue-jira-automation workflow #108

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
30 changes: 15 additions & 15 deletions .github/scripts/git_issues/generate_jira_issue_data.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ if [[ "${git_issue_event_name}" == "issues" ]]; then
if [[ ${git_issue_event_action} == "opened" ]]; then
echo "Generating new jira issue description"
JIRA_EVENT_DESCRIPTION="*Issue Title:* ${git_issue_title}
*Repository:* ${repository}
*Git Issue id:* ${git_issue_id}
*Git User:* ${git_user}
*Git issue Description:*
${git_issue_body}
*Git Issue Creation Time:* ${git_issue_created_at}
*Git Issue URL:* ${git_issue_url}"
*Repository:* ${repository}
*Git Issue id:* ${git_issue_id}
*Git User:* ${git_user}
*Git issue Description:*
${git_issue_body}
*Git Issue Creation Time:* ${git_issue_created_at}
*Git Issue URL:* ${git_issue_url}"

elif [[ ${git_issue_event_action} == "closed" ]]; then
echo "Closing ${akeyless_jira_issue} jira issue description"
JIRA_EVENT_DESCRIPTION="*Git Issue has been closed*
*Git issue closed by:* ${git_user}
*Git Issue Update Time:* ${git_issue_updated_at}
*Git Issue URL:* ${git_issue_url}"
*Git issue closed by:* ${git_user}
*Git Issue Update Time:* ${git_issue_updated_at}
*Git Issue URL:* ${git_issue_url}"
fi
elif [[ ${git_issue_event_name} == "issue_comment" ]]; then
echo "Generation new comment on jira issue ${akeyless_jira_issue}"
JIRA_EVENT_DESCRIPTION="*Git Issue has new comment*
*Git User:* ${git_user}
*Git issue comment:*
${git_issue_comment_body}
*Git Issue Comment Creation Time:* ${git_issue_comment_created_at}
*Git Issue Comment URL:* ${git_issue_comment_url}"
*Git User:* ${git_user}
*Git issue comment:*
${git_issue_comment_body}
*Git Issue Comment Creation Time:* ${git_issue_comment_created_at}
*Git Issue Comment URL:* ${git_issue_comment_url}"
fi

delimiter="$(openssl rand -hex 8)"
Expand Down
74 changes: 5 additions & 69 deletions .github/workflows/git-issues-jira-automation.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Git Issues Jira Automation Pipeline
on:
issues:
types: [opened, closed]
types: [opened]
issue_comment:
types: [created]

Expand All @@ -12,71 +12,7 @@ env:

jobs:
git-issues-jira-automation:
name: git-issues-jira-automation
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Login to Akeyless jira
uses: atlassian/gajira-login@master
env:
JIRA_BASE_URL: ${{ secrets.AKEYLESS_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.AKEYLESS_JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.AKEYLESS_JIRA_ISSUE_TOKEN }}

- name: Generate Git Issue Event Description For Jira
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: .github/scripts/git_issues/generate_jira_issue_data.sh

- name: Find Existing Jira issue
if: env.jira_issue_exist == 'true'
uses: atlassian/gajira-find-issue-key@v3
with:
string: ${{ env.akeyless_jira_issue }}

- name: Create Jira issue
if: env.jira_issue_exist == 'false' && github.event.action == 'opened'
id: create-jira-issue
uses: atlassian/gajira-create@v3
with:
project: ASM
issuetype: Bug-Field
summary: ${{ env.jira_issue_summary }}
description: ${{ env.jira_description }}
fields: ${{ env.jira_fields }}

- name: Log created issue
if: steps.create-jira-issue.outcome == 'success'
run: echo "Jira Issue ${{ steps.create-jira-issue.outputs.issue }} was created"

- name: Label Create Git Issue
uses: actions/github-script@v7
if: steps.create-jira-issue.outcome == 'success'
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["${{ steps.create-jira-issue.outputs.issue }}"]
})

- name: Add Comment On Jira issue
if: env.jira_issue_exist == 'true' && (github.event_name == 'issue_comment' || (github.event_name == 'issues' && github.event.action == 'closed'))
uses: atlassian/gajira-comment@v3
with:
issue: ${{ env.akeyless_jira_issue }}
comment: ${{ env.jira_description }}

- name: Transition issue
if: github.event_name == 'issues' && github.event.action == 'closed' && env.jira_issue_exist == 'true'
id: transition
uses: atlassian/gajira-transition@v3
with:
issue: ${{ env.akeyless_jira_issue }}
transition: "Done"

- name: Issue summary
run: echo '### Github issue automation summary -${{ steps.create-jira-issue.outputs.issue }} ${{ env.jira_description }}! :rocket:' >> $GITHUB_STEP_SUMMARY
uses: akeyless-community/terraform-provider-akeyless/.github/workflows/reusable-git-issues-jira-automation.yaml@main
with:
caller_repo_name: ${{ github.event.repository.name }}
secrets: inherit
89 changes: 89 additions & 0 deletions .github/workflows/reusable-git-issues-jira-automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Reusable Git Issues Jira Automation Pipeline
on:
workflow_call:
inputs:
caller_repo_name:
type: string

env:
AKEYLESS_JIRA_BASE_URL: ${{ secrets.AKEYLESS_JIRA_BASE_URL }}
AKEYLESS_JIRA_USER_EMAIL: ${{ secrets.AKEYLESS_JIRA_USER_EMAIL }}
AKEYLESS_JIRA_ISSUE_TOKEN: ${{ secrets.AKEYLESS_JIRA_ISSUE_TOKEN }}
caller_repo_name: ${{ inputs.caller_repo_name }}

jobs:
git-issues-jira-automation:
name: ${{ inputs.caller_repo_name }}-git-issues-jira-automation
runs-on: ubuntu-20.04
steps:
- name: Checkout terraform-provider-akeyless code
uses: actions/checkout@v4
with:
repository: akeyless-community/terraform-provider-akeyless
ref: main
token: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Akeyless jira
uses: atlassian/gajira-login@master
env:
JIRA_BASE_URL: ${{ secrets.AKEYLESS_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.AKEYLESS_JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.AKEYLESS_JIRA_ISSUE_TOKEN }}

- name: Generate Git Issue Event Description For Jira
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: .github/scripts/git_issues/generate_jira_issue_data.sh

- name: Find Existing Jira issue
if: env.jira_issue_exist == 'true'
uses: atlassian/gajira-find-issue-key@v3
with:
string: ${{ env.akeyless_jira_issue }}
Comment on lines +38 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not used


- name: Create Jira issue
if: env.jira_issue_exist == 'false' && github.event.action == 'opened'
id: create-jira-issue
uses: atlassian/gajira-create@v3
with:
project: ASM
issuetype: Bug-Field
summary: ${{ env.jira_issue_summary }}
description: ${{ env.jira_description }}
fields: ${{ env.jira_fields }}

- name: Log created issue
if: steps.create-jira-issue.outcome == 'success'
run: echo "Jira Issue ${{ steps.create-jira-issue.outputs.issue }} was created"

- name: Add Comment On Jira issue
if: env.jira_issue_exist == 'true' && (github.event_name == 'issue_comment' || (github.event_name == 'issues' && github.event.action == 'closed'))
uses: atlassian/gajira-comment@v3
with:
issue: ${{ env.akeyless_jira_issue }}
comment: ${{ env.jira_description }}
Comment on lines +59 to +64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not used


- name: Prepare Slack Message On Success
if: env.jira_issue_exist == 'false' && github.event.action == 'opened'
id: slack-message-success-creator
run: |
SLACK_MESSAGE="${jira_description}
*Jira Ticket*: https://akeyless.atlassian.net/browse/${{steps.create-jira-issue.outputs.issue}}"
delimiter="$(openssl rand -hex 8)"
echo "slack-message<<${delimiter}" >> $GITHUB_ENV
echo "${SLACK_MESSAGE//$/%0A}" >> $GITHUB_ENV
echo "${delimiter}" >> $GITHUB_ENV

- name: Slack Success Notification
if: env.jira_issue_exist == 'false' && github.event.action == 'opened'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: 'github-public-repo-issues'
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: 'New Git Issue Created'
SLACK_MESSAGE: '${{ env.slack-message }}'
SLACK_USERNAME: githubBot
SLACK_WEBHOOK: ${{ secrets.SLACK_GITHUB_ISSUES_WEBHOOK }}
MSG_MINIMAL: true
SLACK_FOOTER: GitHub Issue To Jira Automation
2 changes: 1 addition & 1 deletion version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this change

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Use Semantic versioning only. Please update the version number before opening a pull request.
v1.7.4
v1.7.5