Skip to content

Fix Docker building (and also build for forks) #2349

Fix Docker building (and also build for forks)

Fix Docker building (and also build for forks) #2349

Workflow file for this run

name: On PR closed
on:
pull_request_target:
types: [ closed ]
# Manual trigger to unassign a contributor and take necessary follow-up actions
# Do not call if PR was successfully merged
workflow_dispatch:
inputs:
pr_number:
description: PR number to process
required: true
type: number
jobs:
collect_parameters:
name: Collect parameters
runs-on: ubuntu-slim
if: >
github.repository == 'JabRef/jabref' &&
(
github.event_name == 'workflow_dispatch' ||
!(
github.event.pull_request.user.login == 'dependabot[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:
pull-requests: read
outputs:
pr_number: ${{ steps.pick.outputs.pr_number }}
pr_url: ${{ steps.pick.outputs.pr_url }}
pr_body: ${{ steps.pick.outputs.pr_body }}
pr_user: ${{ steps.pick.outputs.pr_user }}
steps:
- id: from_dispatch
name: Collect from dispatch
if: github.event_name == 'workflow_dispatch'
env:
PR_NUMBER: ${{ inputs.pr_number }}
uses: actions/github-script@v8
with:
script: |
const {owner, repo} = context.repo;
const prNumber = Number(process.env.PR_NUMBER);
const {data: pr} = await github.rest.pulls.get({ owner, repo, pull_number: prNumber });
core.setOutput("pr_number", String(pr.number));
core.setOutput("pr_url", pr.html_url ?? "");
core.setOutput("pr_body", pr.body ?? "");
core.setOutput("pr_user", pr.user?.login ?? "");
- name: Pick outputs
id: pick
env:
EVENT_NAME: ${{ github.event_name }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_USER: ${{ github.event.pull_request.user.login }}
DISPATCH_BODY: ${{ steps.from_dispatch.outputs.pr_body }}
DISPATCH_NUMBER: ${{ steps.from_dispatch.outputs.pr_number }}
DISPATCH_URL: ${{ steps.from_dispatch.outputs.pr_url }}
DISPATCH_USER: ${{ steps.from_dispatch.outputs.pr_user }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "pr_number=$DISPATCH_NUMBER" >> "$GITHUB_OUTPUT"
echo "pr_url=$DISPATCH_URL" >> "$GITHUB_OUTPUT"
echo "pr_user=$DISPATCH_USER" >> "$GITHUB_OUTPUT"
{
printf 'pr_body<<GH_BODY\n'
printf '%s\n' "$DISPATCH_BODY"
printf 'GH_BODY\n'
} >> "$GITHUB_OUTPUT"
else
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
echo "pr_user=$PR_USER" >> "$GITHUB_OUTPUT"
{
printf 'pr_body<<GH_BODY\n'
printf '%s\n' "$PR_BODY"
printf 'GH_BODY\n'
} >> "$GITHUB_OUTPUT"
fi
determine_issue_number:
name: Determine issue number
needs: collect_parameters
runs-on: ubuntu-slim
permissions:
contents: read
outputs:
issue_number: ${{ steps.get_issue_number.outputs.ticketNumber }}
steps:
- name: Determine issue number
id: get_issue_number
env:
PR_NUMBER: ${{ needs.collect_parameters.outputs.pr_number }}
PR_URL: ${{ needs.collect_parameters.outputs.pr_url }}
PR_BODY: ${{ needs.collect_parameters.outputs.pr_body }}
run: |
echo "PR Number: $PR_NUMBER"
echo "PR URL: $PR_URL"
echo "PR [#$PR_NUMBER]($PR_URL)" >> $GITHUB_STEP_SUMMARY
printf 'PR Body: %s\n' "$PR_BODY" >> $GITHUB_STEP_SUMMARY
ticketNumber=$(printf '%s\n' "$PR_BODY" \
| grep -Eio '(fixes|closes|resolves)\s+(https://github.com/JabRef/jabref/issues/)?#?[0-9]+' \
| grep -Eo '[0-9]+' \
| grep -Ev '^13109$' \
| head -n1 || true)
echo "ticketNumber=$ticketNumber" >> "$GITHUB_OUTPUT"
echo "Determined issue [#$ticketNumber](https://github.com/JabRef/jabref/issues/$ticketNumber)" >> $GITHUB_STEP_SUMMARY
unassign_issue:
name: Mark issue as available
runs-on: ubuntu-slim
needs: [ collect_parameters, determine_issue_number ]
if: >
(needs.determine_issue_number.outputs.issue_number != '') &&
(github.event_name == 'workflow_dispatch' || !github.event.pull_request.merged)
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Remove assignee
run: |
set -euo pipefail
set -x
# "brute force" remove assignee - it might happen that the contributor was unassinged, but the PR closed later; therefore we need " || true" to ignore any error
gh issue edit ${{ needs.determine_issue_number.outputs.issue_number }} --remove-assignee ${{ needs.collect_parameters.outputs.pr_user }} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq
version: 1.0
- name: Check assignees
id: check_assignee
run: |
issue=$(gh issue view ${{ needs.determine_issue_number.outputs.issue_number }} --json assignees)
count=$(echo "$issue" | jq '.assignees | length')
if [ "$count" -gt 0 ]; then
echo "assigned=yes" >> $GITHUB_OUTPUT
else
echo "assigned=no" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove labels assigned, reminder-sent, pinned, and "FirstTimeCodeContribution"
if: steps.check_assignee.outputs.assigned == 'no'
run: |
gh issue edit ${{ needs.determine_issue_number.outputs.issue_number }} --remove-label "📍 Assigned,🔔 reminder-sent,📌 Pinned,FirstTimeCodeContribution"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move issue to "Free to take" in "Good First Issues"
if: steps.check_assignee.outputs.assigned == 'no'
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: "Assigned"
ignored-columns: ""
default-column: "Free to take"
issue-number: ${{ needs.determine_issue_number.outputs.issue_number }}
skip-if-not-in-project: true
- name: Move issue to "Free to take" in "Candidates for University Projects"
if: steps.check_assignee.outputs.assigned == 'no'
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: "Assigned"
ignored-columns: ""
default-column: "Free to take"
issue-number: ${{ needs.determine_issue_number.outputs.issue_number }}
skip-if-not-in-project: true
- name: Comment on PR that unassigned
if: steps.check_assignee.outputs.assigned == 'no'
run: |
echo "Commenting on PR..."
gh issue comment "${{ needs.collect_parameters.outputs.pr_number }}" -b "This pull requests was closed without merging. You have been unassigned from the respective issue #${{ needs.determine_issue_number.outputs.issue_number }}. In case you closed the PR for yourself, you can re-open it. Please also check [After submission of a pull request](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md#after-submission-of-a-pull-request) in [CONTRIBUTING.md](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md)."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
comment_on_resolved_issue:
name: Comment on resolved issue
runs-on: ubuntu-slim
needs: determine_issue_number
if: >
(needs.determine_issue_number.outputs.issue_number != '') &&
(github.event_name != 'workflow_dispatch' && github.event.pull_request.merged)
permissions:
contents: read
issues: write
steps:
- name: Comment on issue
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ needs.determine_issue_number.outputs.issue_number }}
message: |
We think that this issue was fixed. Please head to <https://builds.jabref.org/main> to download a development build and try it out.
For any feedback, add a comment to the pull request at ${{ github.event.pull_request.html_url }}.
remove_download_hint:
name: Remove download hint
runs-on: ubuntu-slim
needs: determine_issue_number
# Link is removed in both cases (merged and closed)
if: needs.determine_issue_number.outputs.issue_number != ''
permissions:
contents: read
issues: write
steps:
- name: Delete download comment
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ needs.determine_issue_number.outputs.issue_number }}
comment-tag: download-link
mode: delete