-
Notifications
You must be signed in to change notification settings - Fork 440
46 lines (40 loc) · 1.93 KB
/
create_diffend_io_links.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
name: Create Diffend.io Links and Comment Text
on:
pull_request:
paths:
- '**.gem'
permissions:
contents: read
jobs:
create_diffend_io_links_and_comment_text:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Diffend.io Links and Comment Text
run: |
# Receive added and removed file names from the git diff, filter out everything besides the gem files and receive
# the basename without the gem file extension
ADDED_GEMS=( $(git diff --name-only --diff-filter=A origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs -r basename -s .gem) )
REMOVED_GEMS=( $(git diff --name-only --diff-filter=D origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs -r basename -s .gem) )
COMMENT_TEXT="Please see the links listed bellow to review the changes applied to the gems:"$'\n'
for i in "${!ADDED_GEMS[@]}"; do
# Receive gem name without version number
GEM_NAME=$(echo ${ADDED_GEMS[i]} | rev | cut -d "-" -f2- | rev)
# Receive added and removed gem version numbers
ADDED_GEM_VERSION=$(echo ${ADDED_GEMS[i]} | rev | cut -d "-" -f1 | rev)
REMOVED_GEM_VERSION=$(echo ${REMOVED_GEMS[i]} | rev | cut -d "-" -f1 | rev)
# Create the link to diffend.io
DIFFEND_LINK=("https://my.diffend.io/gems/${GEM_NAME}/${REMOVED_GEM_VERSION}/${ADDED_GEM_VERSION}")
COMMENT_TEXT+="- [${GEM_NAME} ${REMOVED_GEM_VERSION} -> ${ADDED_GEM_VERSION}](${DIFFEND_LINK})"$'\n'
done
mkdir ./artifacts
echo "$COMMENT_TEXT" > ./artifacts/comment_text.txt
echo ${{ github.event.number }} > ./artifacts/pr_number.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: comment_text_and_pr_number
path: artifacts/