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

JIRA: Use env when creating with custom fields #1786

Merged
merged 7 commits into from
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions .github/workflows/jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Jira sync
steps:
- name: Login
uses: atlassian/gajira-login@v3
uses: atlassian/gajira-login@v2.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to be some kind auth issue so going back to v2.0.0 just in case

env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand All @@ -24,17 +24,38 @@ jobs:
- name: Set ticket type
id: set-ticket-type
run: |
echo "::set-output name=type::GH Issue"
if [[ "${{ github.event_name == 'pull_request' && github.event.action == 'opened' ]]; then
echo "::set-output name=type::PR"
else
echo "::set-output name=type::GH Issue"
fi

- name: Set ticket labels
if: github.event.action == 'opened'
id: set-ticket-labels
run: |
LABELS="[consul-k8s]"
echo "::set-output name=labels::${LABELS}"

- name: Check if team member
if: github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task'
id: is-team-member
run: |
TEAM=consul
ROLE="$(hub api orgs/hashicorp/teams/${TEAM}/memberships/${{ github.actor }} | jq -r '.role | select(.!=null)')"
if [[ -n ${ROLE} ]]; then
echo "Actor ${{ github.actor }} is a ${TEAM} team member"
echo "::set-output name=message::true"
else
echo "Actor ${{ github.actor }} is NOT a ${TEAM} team member"
echo "::set-output name=message::false"
fi
env:
GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }}

- name: Create ticket
if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'Task' ) || ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task' )
uses: tomhjp/gh-action-jira-create@v0.1.3
- name: Create ticket if an issue is filed, or if PR not by a team member is opened
if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'PR' && steps.is-team-member.outputs.message == 'false' )
uses: tomhjp/gh-action-jira-create@v0.2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Going back to 2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I don't think the 0.1.3 made any difference, the issue was Auth was not working when using the action when custom fields were used in JIRA

with:
project: NET
issuetype: "${{ steps.set-ticket-type.outputs.type }}"
Expand All @@ -45,6 +66,10 @@ jobs:
"customfield_10371": { "value": "GitHub" },
"components": [{ "name": "${{ github.event.repository.name }}" }],
"labels": ${{ steps.set-ticket-labels.outputs.labels }} }'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Search
if: github.event.action != 'opened'
Expand Down