From 5154db45e791a53b1721ef13f906a94fc3c2898b Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 14 Jan 2025 09:37:49 -0500 Subject: [PATCH] update workflows --- .github/workflows/create-release.yml | 2 ++ .github/workflows/pr-build.yml | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e38dfab..b07111e 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -39,6 +39,8 @@ jobs: - name: Get the PR that was merged into main id: pr-output + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | info=$(gh pr list --state merged --limit 1 --json title --json body) echo "title=$(echo $info | jq -r '.title')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index cfd088f..bdc98a3 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -5,12 +5,10 @@ on: branches: - main paths-ignore: - - ".github/**" - "**.md" - "**.png" - ".gitignore" - "generate-workflow" - - "**.yml" - "test/**" - "example-workflows/**" @@ -21,6 +19,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: "Only run if last commit was a code change" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git diff-tree --no-commit-id --name-only -r HEAD | sort > changed_files + if ! (grep -q "^src/" changed_files || grep -q "^\.github/workflows/pr-build\.yml$" changed_files); then + echo "No changes in src/ directory or .github/workflows/pr-build.yml" + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + fi + + - name: Set up Node.js uses: actions/setup-node@v4 with: