Skip to content

Commit

Permalink
JIRA: Use env when creating with custom fields (#1786)
Browse files Browse the repository at this point in the history
* Update jira.yaml
  • Loading branch information
David Yu committed Feb 14, 2023
1 parent 732b804 commit fd73492
Showing 1 changed file with 30 additions and 5 deletions.
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
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
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

0 comments on commit fd73492

Please sign in to comment.