Skip to content

Commit

Permalink
Merge pull request #81 from per1234/compare-tag
Browse files Browse the repository at this point in the history
Use previous tag as base when "Compare Performance" workflow triggered by tag
  • Loading branch information
per1234 authored Sep 6, 2021
2 parents 19a08e8 + 4b3fa62 commit b524c45
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/compare-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,42 @@ jobs:
base-ref: ${{ steps.base-ref.outputs.ref }}

steps:
# Repo is required to get the previous tag ref that is the base of the comparison on tag push triggered run.
- name: Checkout repository
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: actions/checkout@v2

- name: Determine comparison ref
id: base-ref
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "::set-output name=ref::${{ github.event.inputs.comparison-ref }}"
COMPARISON_REF="${{ github.event.inputs.comparison-ref }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "::set-output name=ref::${{ github.base_ref }}"
COMPARISON_REF="${{ github.base_ref }}"
elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
COMPARISON_REF="$( \
git ls-remote \
--quiet \
--tags \
--refs \
--sort=version:refname | \
cut \
--delimiter='/' \
--fields=3 | \
tail -2 | \
head -1
)"
else
echo "::set-output name=ref::${{ github.event.before }}"
COMPARISON_REF="${{ github.event.before }}"
fi
if [[ "$COMPARISON_REF" == "" ]]; then
echo "::error::Unable to determine comparison ref"
exit 1
fi
echo "::set-output name=ref::$COMPARISON_REF"
run:
name: Run at ${{ matrix.data.ref }} (${{ matrix.data.description }})
needs: init
Expand Down

0 comments on commit b524c45

Please sign in to comment.