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.7 test-multiple-repositories: name: Test with multiple repositories runs-on: ${{ matrix.platform }} strategy: fail-fast: false matrix: platform: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout into dir1 uses: actions/checkout@v2 with: fetch-depth: 0 path: dir1 - name: Run changed-files with defaults on the dir1 id: changed-files-dir1 uses: ./dir1 with: path: dir1 - name: Show output run: | echo '${{ toJSON(steps.changed-files-dir1.outputs) }}' shell: bash - name: List all modified files run: | for file in "${{ steps.changed-files-dir1.outputs.modified_files }}"; do echo "$file" done shell: bash - name: Checkout into dir2 uses: actions/checkout@v2 with: fetch-depth: 0 path: dir2 - name: Run changed-files with defaults on the dir2 id: changed-files-dir2 uses: ./dir2 with: path: dir2 - name: Show output run: | echo '${{ toJSON(steps.changed-files-dir2.outputs) }}' shell: bash - name: List all modified files run: | for file in "${{ steps.changed-files-dir2.outputs.modified_files }}"; do echo "$file" done shell: bash 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 forward slash separator id: changed-files-forward-slash uses: ./ with: separator: "/" - name: Show output run: | echo '${{ toJSON(steps.changed-files-forward-slash.outputs) }}' shell: bash - name: Run changed-files with pipe separator id: changed-files-pipe uses: ./ with: separator: "|" - name: Show output run: | echo '${{ toJSON(steps.changed-files-pipe.outputs) }}' 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: Show output run: | echo '${{ toJSON(steps.changed-files-specific.outputs) }}' shell: bash - name: Verify any_changed for specific 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: Verify any_deleted for specific files if: "!contains(steps.changed-files-specific.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_deleted }})" exit 1 fi shell: bash - name: Run changed-files with specific files comma check duplicates id: changed-files-specific-duplicate-output uses: ./ with: files: | entrypoint.sh *.sh - name: Verify all_changed_and_modified_files files has no duplicates if: contains(steps.changed-files-specific-duplicate-output.outputs.all_modified_files, 'entrypoint.sh') run: | ALL_CHANGED_AND_MODIFIED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_modified_files }}) UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES=$(echo "$ALL_CHANGED_AND_MODIFIED_FILES" | tr ' ' '\n' | sort -u | xargs) if [[ "$ALL_CHANGED_AND_MODIFIED_FILES[@]" != "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES[@]" ]]; then echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES" got $ALL_CHANGED_AND_MODIFIED_FILES" exit 1 fi 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: Show output run: | echo '${{ toJSON(steps.changed-files-specific-comma.outputs) }}' shell: bash - 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-comma.outputs.any_changed }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_changed }})" exit 1 fi shell: bash - name: Verify any_deleted files comma separator if: "!contains(steps.changed-files-specific-comma.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-comma.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_deleted }})" exit 1 fi shell: bash - name: Run changed-files with specific files pipe separator id: changed-files-specific-pipe uses: ./ with: files: | .github/workflows/test.yml action.yml separator: "|" - name: Show output run: | echo '${{ toJSON(steps.changed-files-specific-pipe.outputs) }}' shell: bash - name: Verify any_changed files comma separator if: "!contains(steps.changed-files-specific-pipe.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.all_modified_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-pipe.outputs.any_changed }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_changed }})" exit 1 fi shell: bash - name: Verify any_deleted files comma separator if: "!contains(steps.changed-files-specific-pipe.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-pipe.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_deleted }})" exit 1 fi shell: bash - name: Run changed-files with specific files forward slash separator id: changed-files-specific-forward-slash uses: ./ with: files: | .github/workflows/test.yml action.yml separator: "/" - name: Show output run: | echo '${{ toJSON(steps.changed-files-specific-forward-slash.outputs) }}' shell: bash - name: Verify any_changed files comma separator if: "!contains(steps.changed-files-specific-forward-slash.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.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-forward-slash.outputs.any_changed }})" exit 1 fi shell: bash - name: Verify any_deleted files comma separator if: "!contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_deleted }})" exit 1 fi shell: bash - name: Run changed-files with specific files from a source file id: changed-files-specific-source-file uses: ./ with: files_from_source_file: | test/changed-files-list.txt test/changed-files-list.txt files: | .github/workflows/rebase.yml - name: Verify any_changed from source files if: "!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-source-file.outputs.any_changed }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_changed }})" exit 1 fi shell: bash - name: Verify any_deleted from source files if: "!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-source-file.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_deleted }})" exit 1 fi shell: bash - name: Show output run: | echo '${{ toJSON(steps.changed-files-specific-source-file.outputs) }}' shell: bash - name: Run changed-files with specific files from a source file using a comma separator id: changed-files-specific-comma-source-file uses: ./ with: files_from_source_file: | test/changed-files-list.txt separator: "," - name: Show output run: | echo '${{ toJSON(steps.changed-files-specific-comma-source-file.outputs) }}' shell: bash - name: Verify any_changed files comma separator if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }})" exit 1 fi shell: bash - name: Verify any_deleted files with comma separator if: "!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '.github/workflows/test.yml')" run: | if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }})" exit 1 fi shell: bash - name: Run changed-files with custom sha id: changed-files-custom-sha uses: ./ with: sha: ${{ github.event.pull_request.head.sha }} - name: Show output run: | echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}' shell: bash - name: Get branch name id: branch-name uses: tj-actions/branch-names@v4.9 - uses: nrwl/last-successful-commit-action@v1 id: last_successful_commit with: branch: ${{ steps.branch-name.outputs.base_ref_branch }} workflow_id: 'test.yml' github_token: ${{ secrets.GITHUB_TOKEN }} - name: Run changed-files with a custom base sha id: changed-files-custom-base-sha uses: ./ with: base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }} - name: Show output run: | echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}' shell: bash - name: Run changed-files with specific files (only-changed) id: changed-files-specific-only-changed uses: ./ with: files: | .github/workflows/test.yml - name: Verify only_changed files if: steps.changed-files-specific-only-changed.outputs.other_changed_files != '' run: | if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_changed }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_changed }})" exit 1 fi shell: bash - name: Verify only_deleted files if: steps.changed-files-specific-only-changed.outputs.other_deleted_files != '' run: | if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_deleted }}" != "false" ]]; then echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_deleted }})" exit 1 fi shell: bash - name: Show output run: | echo '${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}' shell: bash