-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
79 lines (71 loc) · 2.21 KB
/
action.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: "Gem Compare"
description: "Compare different gem versions"
branding:
icon: "search"
color: "red"
inputs:
lockfile:
description: "File to diff"
default: "Gemfile.lock"
required: false
gem_compare_version:
description: "Version of the gem-compare plugin"
default: "1.2.1"
required: false
pr_diff:
description: "Output from 'git diff' for Gemfile.lock"
default: ""
required: false
pr_number:
description: "The number of the pull request to comment in"
default: 1
required: false
github-token:
description: "The repo scoped token generated by GitHub Actions"
required: true
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
fetch-depth: 2 # https://github.com/actions/checkout#checkout-head
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
# Ensure our scripts can be found when running the action
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Get pull request number
shell: bash
run: |
echo "PR_NUMBER=${{ github.event.pull_request.number || inputs.pr_number }}" >> $GITHUB_ENV
- name: Get pull request diff from input
if: ${{ inputs.pr_diff != '' }}
shell: bash
run: |
{
echo 'PR_DIFF<<EOF'
cat ${{ inputs.pr_diff }}
echo EOF
} >> "$GITHUB_ENV"
- name: Get pull request diff from repo
if: ${{ inputs.pr_diff == '' }}
shell: bash
run: |
{
echo 'PR_DIFF<<EOF'
git diff HEAD^ HEAD -- "${{ inputs.lockfile }}"
echo EOF
} >> "$GITHUB_ENV"
- name: Run gem install gem-compare
shell: bash
run: |
with_retries gem install gem-compare --version ${{ inputs.gem_compare_version }} || true
- name: Run compare steps
shell: bash
run: |
compare_gem_versions
env:
GITHUB_TOKEN: ${{ inputs.github-token }}