Skip to content

ci fix for running multiple times #39

ci fix for running multiple times

ci fix for running multiple times #39

Workflow file for this run

name: CI
on:
push:
pull_request:
branches: [ master ]
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.event.pull_request.head.ref || github.ref_name }}
cancel-in-progress: true
jobs:
detect-open-pr:
name: Detect open PR
runs-on: ubuntu-latest
outputs:
has_open_pr: ${{ steps.check.outputs.has_open_pr }}
steps:
- name: Check if pushed branch already has an open PR
id: check
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
REPO: ${{ github.repository }}
OWNER: ${{ github.repository_owner }}
run: |
if [ "$EVENT_NAME" != "push" ]; then
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$BRANCH_NAME" = "master" ]; then
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
exit 0
fi
COUNT=$(gh api \
-H "Accept: application/vnd.github+json" \
"/repos/$REPO/pulls?state=open&head=$OWNER:$BRANCH_NAME" \
--jq 'length')
echo "Open PR count for branch '$OWNER:$BRANCH_NAME': $COUNT"
if [ "$COUNT" -gt 0 ]; then
echo "has_open_pr=true" >> "$GITHUB_OUTPUT"
else
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
fi
build:
name: Build on ${{ matrix.os }}
needs: detect-open-pr
if: >
github.event_name == 'pull_request' ||
github.ref == 'refs/heads/master' ||
needs.detect-open-pr.outputs.has_open_pr == 'false'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
xorg-dev \
libgl1-mesa-dev
- name: Configure CMake
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DIMGADDONS_BUILD_PREVIEW=ON \
-DIMGADDONS_RUNTIME_OUTPUT_DIR="${{ github.workspace }}/build/bin"
- name: Build
run: |
cmake --build build --config Release --parallel