Skip to content

Combine SearchableComboBox and TextField for adding fields in Custom Entry Types #720

Combine SearchableComboBox and TextField for adding fields in Custom Entry Types

Combine SearchableComboBox and TextField for adding fields in Custom Entry Types #720

Workflow file for this run

name: Link PR to Issue
on:
pull_request_target:
types: [opened, reopened, edited]
jobs:
determine_issue_number:
name: Determine issue number
runs-on: ubuntu-latest
if: >
(github.repository == 'JabRef/jabref') &&
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') &&
!(
(github.event.pull_request.user.login == 'dependabot[bot]') || (github.event.pull_request.user.login == 'renovate-bot') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
permissions:
contents: read
outputs:
issue_number: ${{ steps.get_issue_number.outputs.ticketNumber }}
steps:
- name: echo PR data
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
echo "PR Number: $PR_NUMBER"
echo "PR URL: $PR_URL"
cat <<EOF
PR Body:
$PR_BODY
EOF
- name: Determine issue number
id: get_issue_number
uses: koppor/ticket-check-action@add-output
with:
token: ${{ secrets.GITHUB_TOKEN }}
ticketLink: 'https://github.com/JabRef/jabref/issues/%ticketNumber%'
ticketPrefix: '#'
titleRegex: '^#(?<ticketNumber>\d+)'
branchRegex: '^(?<ticketNumber>\d+)'
# Matches GitHub's closes/fixes/resolves #{number}, but does not match our example `Closes #13109` in PULL_REQUEST_TEMPLATE
# Also matches URLs that are wrapped in `<>`.
bodyRegex: '(?<action>fixes|closes|resolves|refs)\s+<?(?:https?:\/\/github\.com\/JabRef\/jabref\/issues\/)?#?(?<ticketNumber>(?!13109\b)\d+)>?'
bodyRegexFlags: 'i'
outputOnly: true
- run: echo "${{ steps.get_issue_number.outputs.ticketNumber }}"
- name: Issue number present
if: steps.get_issue_number.outputs.ticketNumber == '-1'
run: |
echo "No valid ticket number found!"
exit 1
move_issue:
name: Mark issue as in progress
# after determine_issue_number to ensure that there is only one failure because of no ticket number
needs: determine_issue_number
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Move issue to "In Progress" in "Good First Issues"
uses: m7kvqbe1/github-action-move-issues/@main
with:
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
project-url: "https://github.com/orgs/JabRef/projects/5"
target-labels: "📍 Assigned"
target-column: "In Progress"
ignored-columns: ""
default-column: "In Progress"
issue-number: ${{ needs.determine_issue_number.outputs.issue_number }}
skip-if-not-in-project: true
- name: Move issue to "In Progress" in "Candidates for University Projects"
uses: m7kvqbe1/github-action-move-issues/@main
with:
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
project-url: "https://github.com/orgs/JabRef/projects/3"
target-labels: "📍 Assigned"
target-column: "In Progress"
ignored-columns: ""
default-column: "In Progress"
issue-number: ${{ needs.determine_issue_number.outputs.issue_number }}
skip-if-not-in-project: true
ensure_assignment:
name: Ensure that contributor is assigned (fails if not commented on issue)
if: github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
# after determine_issue_number to ensure that there is only one failure because of no ticket number
needs: determine_issue_number
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v6
with:
show-progress: 'false'
- name: Assign PR creator to issue
run: |
set -e
echo "Updating issue '${{ needs.determine_issue_number.outputs.issue_number }}'"
# "gh issue edit" cannot be used - workaround found at https://github.com/cli/cli/issues/9620#issuecomment-2703135049
ASSIGNEES=$(gh api /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --jq '[.assignees[].login]')
# Check if the user is already assigned
if echo "$ASSIGNEES" | jq -e '. | index("${{ github.event.pull_request.user.login }}")' >/dev/null; then
echo "User '${{ github.event.pull_request.user.login }}' is already an assignee. No update needed."
echo "Debug: $ASSIGNEES"
exit 0
fi
# Append the new assignee
UPDATED_ASSIGNEES=$(echo "$ASSIGNEES" | jq --arg new "${{ github.event.pull_request.user.login }}" '. + [$new]')
LABELS=$(gh api repos/${{ github.repository }}/issues/${{ needs.determine_issue_number.outputs.issue_number }}/labels --jq '.[].name')
LABEL=$(echo "$LABELS" | grep -E '^good (first|second|third|forth) issue$' || true)
if [ -n "$LABEL" ]; then
echo "✅ Found label: $LABEL"
SILENT=false
# Apply label
gh issue edit "${{ github.event.pull_request.number }}" --add-label "$LABEL"
else
echo "🚫 Silent fail if not possible to add assignee"
SILENT=true
fi
# Update issue with the new assignee list
echo "Updating issue #${{ needs.determine_issue_number.outputs.issue_number }} updated with assignees: $UPDATED_ASSIGNEES..."
if [ "$SILENT" = true ]; then
gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}") || true
else
gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}")
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add label "📌 Pinned"
run: gh issue edit ${{ needs.determine_issue_number.outputs.issue_number }} --add-label "📌 Pinned"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}