tree-sitter/.github/workflows/CICD.yml
Andrew Hlynskyi 7bc2bb605e cicd: switch main workflow to work on any branch except release/v* prefixed
The `release/v*` prefixed branches can be used only with a PR opened on
such branches. The release branches only accepted in the main repo
and not from forks.

Also this workflow enables runining on every `push` unconditionaly.
This leads to parallel runs on `push` and `pull_request` events
and that would seen in PR checks also in parallel, but this is
useful because checks that run on the `push` event runs on
head ref while checks on the `pull_request` event runs on
an additional `refs/pull/<PR>/merge` ref what is created
by Github on every push to a PR to check that it can be
merged to a target branch without conflicts and passed checks.
2023-04-10 21:20:36 +03:00

79 lines
1.9 KiB
YAML

name: CICD
on:
workflow_dispatch:
pull_request:
push:
branches-ignore:
- release/v*
concurrency:
group: >
${{ github.workflow }} @ ${{
github.ref == 'refs/heads/master' && github.ref_name || ''
}}${{
github.ref == 'refs/heads/master' && github.sha
|| github.event.pull_request.head.label || github.head_ref || github.ref
}}
cancel-in-progress: true
jobs:
init:
name: Init
runs-on: ubuntu-latest
steps:
- name: Get PR head ref
if: ${{ github.event_name == 'pull_request' }}
id: ref
run: |
echo "ref=refs/pull/${{ github.event.pull_request.number }}/head" >> $GITHUB_OUTPUT
outputs:
ref: >-
${{
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/v'))
&& steps.ref.outputs.ref
|| github.ref
}}
fast_checks:
name: Fast checks
uses: ./.github/workflows/fast_checks.yml
full_checks:
name: Full Rust checks
needs: fast_checks
uses: ./.github/workflows/full_rust_checks.yml
min_version:
name: Minimum supported rust version
needs: fast_checks
uses: ./.github/workflows/msrv.yml
with:
package: tree-sitter-cli
sanitize:
name: Sanitize
needs: [init, fast_checks]
uses: ./.github/workflows/sanitize.yml
build:
name: Build & Test
needs: [init, fast_checks]
uses: ./.github/workflows/build.yml
with:
ref: ${{ needs.init.outputs.ref }}
release:
name: Release
needs: [init, fast_checks, full_checks, min_version, build, sanitize]
if: >
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.head_ref, 'release/v')
uses: ./.github/workflows/release.yml
with:
ref: ${{ needs.init.outputs.ref }}
publish:
name: Publish
needs: release
uses: ./.github/workflows/publish.yml