Merge pull request #121 from github/dependabot/github_actions/github-… #287
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: acceptance | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
# Detects changes to any of the source files for entitlements-github-plugin | |
changes: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
outputs: | |
has_change: ${{ steps.diff.outputs.has_change}} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: fetch-base | |
if: github.event_name == 'pull_request' | |
name: fetch the latest commit in the base branch to diff against | |
run: git fetch --no-tags --prune --depth=1 origin '+refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}' | |
- id: diff | |
name: diff against the base branch latest commit for specific paths | |
run: | | |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
git diff \ | |
origin/${{ github.base_ref }} \ | |
HEAD \ | |
-- \ | |
'bin/**' \ | |
'lib/**' \ | |
'script/**' \ | |
'spec/**' \ | |
'vendor/**' \ | |
'.ruby-version' \ | |
'entitlements-github-plugin.gemspec' \ | |
'Gemfile' \ | |
'Gemfile.lock' \ | |
> diff.txt | |
# If the diff file is not empty, it has changes. | |
if [ -s diff.txt ]; then | |
echo "::set-output name=has_change::true" | |
fi | |
elif [ "$GITHUB_EVENT_NAME" = "push" ]; then | |
echo "::set-output name=has_change::true" | |
fi | |
acceptance: | |
needs: changes | |
runs-on: ubuntu-latest-xl | |
name: acceptance | |
permissions: | |
contents: read | |
steps: | |
# If source files were not changed, we don't need the acceptance test suite | |
- name: bypass | |
if: ${{ needs.changes.outputs.has_change != 'true' }} | |
run: | | |
echo "✅ Bypassing acceptance tests - they are not required for this change" | |
- name: checkout | |
if: ${{ needs.changes.outputs.has_change == 'true' }} | |
uses: actions/checkout@v4 | |
# Use Docker layer caching for 'docker build' and 'docker-compose build' commands. | |
# https://github.com/satackey/action-docker-layer-caching/releases/tag/v0.0.11 | |
- uses: satackey/action-docker-layer-caching@46d2c640b1d8ef50d185452ad6fb324e6bd1d052 # pin@46d2c640b1d8ef50d185452ad6fb324e6bd1d052 | |
if: ${{ needs.changes.outputs.has_change == 'true' }} | |
continue-on-error: true | |
- name: acceptance tests | |
if: ${{ needs.changes.outputs.has_change == 'true' }} | |
run: script/cibuild-entitlements-github-plugin-acceptance | |
- name: acceptance tests passed | |
run: echo "✅ The acceptance test suite has passed" |