forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (58 loc) · 2.35 KB
/
no-old-refs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#####################################################################################
# GitHub Action to check references to closed issues in code.
#
# Workflow starts when:
# 1) push on master branch
# 2) pull request is opened or synchronized or reopened
#
#####################################################################################
name: "Check no closed issue references"
on:
push:
branches: [ master ]
pull_request:
branches: '*'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check_issues:
if: github.repository == 'checkstyle/checkstyle'
runs-on: ubuntu-22.04
steps:
- name: Download checkstyle
uses: actions/checkout@v4
- name: PR linked issues
id: links
uses: mondeja/pr-linked-issues-action@v2
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#######################################################################
# Linked issues, if present, are received in the following format:
# 37,38
# We convert it into:
# https://github.com/checkstyle/checkstyle/issues/37
# https://github.com/checkstyle/checkstyle/issues/38
#######################################################################
- name: Format linked issues
id: format-linked-issues
if: github.event_name == 'pull_request'
run: |
LINKED_ISSUES=${{ steps.links.outputs.issues }}
LINKED_ISSUES_FORMATTED=/tmp/linked_issues
CHECKSTYLE_ISSUE_URL="https:\/\/github.com\/checkstyle\/checkstyle\/issues\/"
if [ -n "$LINKED_ISSUES" ]; then
# shellcheck disable=SC2001
echo $LINKED_ISSUES | sed -e 's/,/\n/g' >> $LINKED_ISSUES_FORMATTED
sed -i "s/^/$CHECKSTYLE_ISSUE_URL/" $LINKED_ISSUES_FORMATTED
fi
echo "linked-issues-formatted=$LINKED_ISSUES_FORMATTED" >> "$GITHUB_OUTPUT"
- name: Check Issues
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
LINKED_ISSUES: '${{ steps.format-linked-issues.outputs.linked-issues-formatted }}'
PR_HEAD_REPO_NAME: "${{ github.event.pull_request.head.repo.full_name }}"
GITHUB_HEAD_REF: "${{ github.head_ref }}"
run: |
./.ci/no-old-refs.sh