3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 23:44:46 +00:00
changed-files/.github/workflows/test.yml
2021-06-18 19:09:00 -04:00

132 lines
3.9 KiB
YAML

name: CI
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- main
jobs:
shellcheck:
name: Run shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout to branch
uses: actions/checkout@v2
- name: shellcheck
uses: reviewdog/action-shellcheck@v1.5
test-no-head-sha:
name: Test changed-files missing head sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout to branch
uses: actions/checkout@v2
- name: Run changed-files with defaults
id: changed-files
continue-on-error: true
uses: ./
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
test:
name: Test changed-files
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run changed-files with defaults
id: changed-files
uses: ./
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash
- name: List all modified files
run: |
for file in "${{ steps.changed-files.outputs.modified_files }}"; do
echo $file
done
shell:
bash
- name: Run step when README.md changes
if: contains(steps.changed-files.outputs.modified_files, 'README.md')
run: |
echo "Your README.md has been modified ${{ steps.changed-files.outputs.modified_files }}."
shell:
bash
- name: Run changed-files with comma separator
id: changed-files-comma
uses: ./
with:
separator: ","
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-comma.outputs) }}"
shell:
bash
- name: Run changed-files with specific files
id: changed-files-specific
uses: ./
with:
files: |
.github/workflows/test.yml
action.yml
- name: Verify any_changed files
if: "!contains(steps.changed-files-specific.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
- name: Run changed-files with specific files comma separator
id: changed-files-specific-comma
uses: ./
with:
files: |
.github/workflows/test.yml
action.yml
separator: ","
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}"
shell:
bash