File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -34,17 +34,42 @@ jobs:
34
34
base-ref : ${{ steps.base-ref.outputs.ref }}
35
35
36
36
steps :
37
+ # Repo is required to get the previous tag ref that is the base of the comparison on tag push triggered run.
38
+ - name : Checkout repository
39
+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
40
+ uses : actions/checkout@v2
41
+
37
42
- name : Determine comparison ref
38
43
id : base-ref
39
44
run : |
40
45
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
41
- echo "::set-output name=ref:: ${{ github.event.inputs.comparison-ref }}"
46
+ COMPARISON_REF=" ${{ github.event.inputs.comparison-ref }}"
42
47
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
43
- echo "::set-output name=ref::${{ github.base_ref }}"
48
+ COMPARISON_REF="${{ github.base_ref }}"
49
+ elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
50
+ COMPARISON_REF="$( \
51
+ git ls-remote \
52
+ --quiet \
53
+ --tags \
54
+ --refs \
55
+ --sort=version:refname | \
56
+ cut \
57
+ --delimiter='/' \
58
+ --fields=3 | \
59
+ tail -2 | \
60
+ head -1
61
+ )"
44
62
else
45
- echo "::set-output name=ref:: ${{ github.event.before }}"
63
+ COMPARISON_REF=" ${{ github.event.before }}"
46
64
fi
47
65
66
+ if [[ "$COMPARISON_REF" == "" ]]; then
67
+ echo "::error::Unable to determine comparison ref"
68
+ exit 1
69
+ fi
70
+
71
+ echo "::set-output name=ref::$COMPARISON_REF"
72
+
48
73
run :
49
74
name : Run at ${{ matrix.data.ref }} (${{ matrix.data.description }})
50
75
needs : init
You can’t perform that action at this time.
0 commit comments