88 description : " Version of the gem-compare plugin"
99 default : " 1.2.1"
1010 required : false
11- pr_title :
12- description : " String with gem name and from/to versions "
13- default : " Bump pg from 1.4.0 to 1.4.1 "
11+ pr_diff :
12+ description : " Output from 'git diff' for Gemfile.lock "
13+ default : " "
1414 required : false
1515 pr_number :
1616 description : " The number of the pull request to comment in"
@@ -25,68 +25,46 @@ runs:
2525 steps :
2626 - uses : ruby/setup-ruby@v1
2727 with :
28- ruby-version : 3.1
29-
30- - name : Extract info from pull request
31- shell : bash
32- run : |
33- echo "PR_NUMBER=${{ github.event.pull_request.number || inputs.pr_number }}" >> $GITHUB_ENV
34- echo "PR_TITLE=${{ github.event.pull_request.title || inputs.pr_title }}" >> $GITHUB_ENV
28+ ruby-version : 3.2
3529
3630 # Ensure our scripts can be found when running the action
3731 # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file
3832 - run : echo "${{ github.action_path }}" >> $GITHUB_PATH
3933 shell : bash
4034
41- - name : Parse pull request title
35+ - name : Get pull request number
4236 shell : bash
4337 run : |
44- echo "COMPARE_GEM=$(echo $PR_TITLE | parse_title name)" >> $GITHUB_ENV
45- echo "COMPARE_FROM_VERSION=$(echo $PR_TITLE | parse_title from)" >> $GITHUB_ENV
46- echo "COMPARE_TO_VERSION=$(echo $PR_TITLE | parse_title to)" >> $GITHUB_ENV
38+ echo "PR_NUMBER=${{ github.event.pull_request.number || inputs.pr_number }}" >> $GITHUB_ENV
4739
48- - name : Post Diffend URL
40+ - name : Get pull request diff from input
41+ if : ${{ inputs.pr_diff != '' }}
4942 shell : bash
50- env :
51- GITHUB_TOKEN : ${{ inputs.github-token }}
5243 run : |
53- echo "https://my.diffend.io/gems/$COMPARE_GEM/$COMPARE_FROM_VERSION/$COMPARE_TO_VERSION" >> comment0.txt
54- with_retries gh pr comment $PR_NUMBER --body-file comment0.txt --repo ${{ github.repository }}
44+ {
45+ echo 'PR_DIFF<<EOF'
46+ cat ${{ inputs.pr_diff }}
47+ echo EOF
48+ } >> "$GITHUB_ENV"
5549
56- - name : Run gem install gem-compare
50+ - name : Get pull request diff from repo
51+ if : ${{ inputs.pr_diff == '' }}
5752 shell : bash
5853 run : |
59- with_retries gem install gem-compare --version ${{ inputs.gem_compare_version }} || true
54+ {
55+ echo 'PR_DIFF<<EOF'
56+ git diff HEAD^ HEAD -- Gemfile.lock
57+ echo EOF
58+ } >> "$GITHUB_ENV"
6059
61- - name : Run gem compare
60+ - name : Run gem install gem- compare
6261 shell : bash
6362 run : |
64- with_retries gem compare $COMPARE_GEM $COMPARE_FROM_VERSION $COMPARE_TO_VERSION > compare_output.txt || true
63+ with_retries gem install gem- compare --version ${{ inputs.gem_compare_version }} || true
6564
66- - name : Run gem compare --diff
65+ - name : Run compare steps
6766 shell : bash
6867 run : |
69- with_retries gem compare --diff $COMPARE_GEM $COMPARE_FROM_VERSION $COMPARE_TO_VERSION > compare_diff.txt || true
70-
71- - name : Run gh pr comment
72- shell : bash
68+ compare_gem_versions
7369 env :
7470 GITHUB_TOKEN : ${{ inputs.github-token }}
75- run : |
76- echo "## <code>gem compare $COMPARE_GEM $COMPARE_FROM_VERSION $COMPARE_TO_VERSION</code>" > comment1.txt
77- echo '' >> comment1.txt
78- echo '````ruby' >> comment1.txt
79- cat compare_output.txt >> comment1.txt
80- echo '````' >> comment1.txt
81- echo '' >> comment1.txt
82-
83- echo "<Details><Summary><h2><code>gem compare --diff"\
84- "$COMPARE_GEM $COMPARE_FROM_VERSION $COMPARE_TO_VERSION</code></h2></Summary>" >> comment2.txt
85- echo '' >> comment2.txt
86- echo '````ruby' >> comment2.txt
87- cat compare_diff.txt >> comment2.txt
88- echo '````' >> comment2.txt
89- echo '</Details>' >> comment2.txt
90-
91- with_retries gh pr comment $PR_NUMBER --body-file comment1.txt --repo ${{ github.repository }} || true
92- gh pr comment $PR_NUMBER --body-file comment2.txt --repo ${{ github.repository }} || true
0 commit comments