1on:
2  push:
3    branches: [ staging, trying ]
4  pull_request_target:
5
6name: Clippy check
7jobs:
8  clippy:
9    runs-on: ubuntu-latest
10    permissions:
11      checks: write
12    steps:
13      - uses: actions/checkout@v2
14        if: github.event_name == 'pull_request_target'
15        with:
16          ref: refs/pull/${{ github.event.number }}/head
17      - uses: actions/checkout@v2
18        if: github.event_name != 'pull_request_target'
19      - run: sed -n 's,^rust-version = "\(.*\)"$,RUSTUP_TOOLCHAIN=\1,p' Cargo.toml >> $GITHUB_ENV
20      - run: rustup toolchain install $RUSTUP_TOOLCHAIN
21      - run: rustup component add clippy
22      - uses: actions-rs/clippy-check@v1
23        with:
24          token: ${{ secrets.GITHUB_TOKEN }}
25          args: --tests --examples -- -D warnings
26