Skip to content

Unify workflows

Unify workflows #10

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize, edited]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
needs-test:
name: Needs Test
runs-on: ubuntu-latest
steps:
- name: Detect Swift files from diff
id: detect-swift-files
run: |
DIFF="$(gh pr view ${{ github.event.pull_request.html_url }} --json files --jq '.files | map(.path)' | jq -rc '.[]')"
detect_list=('.swift' 'Package.resolved' '.github/workflows/test.yml' '.github/versions.json')
value=false
for file in $detect_list; do
if [ $(echo "$DIFF" | grep "$file" | wc -l | tr -d ' ') -gt 0 ]; then
value=true
break
fi
done
echo result=$value >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
outputs:
result: ${{ steps.detect-swift-files.outputs.result }}
test:
name: Test
needs: needs-test
if: ${{ fromJson(needs.needs-test.outputs.result) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test
run: swift test
danger:
name: Danger
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Danger
uses: 417-72KI/danger-swiftlint@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}