From c259d8fd8fddbe94ea8198d01b6d058b02cda77f Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 14:45:29 +0200 Subject: [PATCH 01/29] WIP --- .github/workflows/test.yml | 39 ++++++++++ README.md | 67 +++++++++------- action.yml | 153 ++++++++++++++++++++++++++++++++----- 3 files changed, 212 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c3f4330 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +on: + push: + branches: + - feat/add-action + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + changes: ${{ steps.changes.outputs.changed }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: "./" + id: changes + with: + include-paths: "." + exclude-paths: | + ^docs/ + ^\.github/workflows/ + ^README\.md$ + + - run: | + echo "Changed: ${{ steps.changes.outputs.changed }}" + echo "Base SHA: ${{ steps.changes.outputs.base_sha }}" + echo "Head SHA: ${{ steps.changes.outputs.head_sha }}" + echo "Changed files: ${{ steps.changes.outputs.changed_files }}" + + deploy: + needs: check + if: needs.check.outputs.changes == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - run: echo "insert deploy here" diff --git a/README.md b/README.md index 62e94a5..e8e1ea7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ -# Arbeidstilsynet/action-noop +# Arbeidstilsynet/action-check-changes -> **Note:** This is a template repository for creating simple composite GitHub Actions. -> -> After creating the new repo you should enable "Allow auto-merge" and "Automatically delete head branches" in Settings -> General -> Pull Requests. +Action to check for changes to files since last successful workflow run. -A no-op GitHub Action that echoes inputs and sets outputs. +This action can be used for safe continuous delivery/deployment taking into consideration previous runs. ## Versioning @@ -14,46 +12,61 @@ If you have to make breaking changes to the action, bump the version. ## Requirements -- None +Requires full commit history. When configuring [actions/checkout](https://github.com/actions/checkout), make sure to set `fetch-depth: 0`. + +The job must have permission for `actions: read` for the action to retrieve run history through the GitHub API. ## Inputs -| Name | Description | Required | Default | -|--------------|--------------------|----------|-----------------| -| `input-one` | First input value | Yes | | -| `input-two` | Second input value | No | `default-value` | +| Name | Required | Default | Description | +|-----------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `workflow-file` | No | (auto-detect) | Workflow filename whose last successful run determines the base commit. If omitted, auto-detected from `GITHUB_WORKFLOW_REF`; if none found falls back to repo root commit. | +| `include-paths` | Yes | — | Whitespace/newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | +| `exclude-paths` | No | (empty) | Whitespace/newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | ## Outputs -| Name | Description | -|-------------|-----------------------| -| `output-one`| Echo of input-one | -| `output-two`| Echo of input-two | +| Name | Description | +|-----------------|-------------------------------------------------------------------------------------------------------| +| `changed` | `true` if any included (and not excluded) paths changed between base and head. | +| `base_sha` | The base commit SHA used for the diff (last successful run’s head, or fallback). | +| `head_sha` | The current commit SHA. | +| `changed_files` | Newline separated list of changed files after exclusions. URL-escaped newlines in raw output context. | ## Usage ```yaml -name: Example No-op Action Usage - on: push: branches: - main jobs: - noop-job: + check: runs-on: ubuntu-latest + permissions: + contents: read + actions: read + outputs: + changed: ${{ steps.changes.outputs.changed }} steps: - - uses: actions/checkout@v4 - - - uses: Arbeidstilsynet/action-noop@v1 - id: noop + - uses: actions/checkout@v5 with: - input-one: "Hello" - input-two: "World" + fetch-depth: 0 - - name: Show outputs - run: | - echo "Output one: ${{ steps.noop.outputs.output-one }}" - echo "Output two: ${{ steps.noop.outputs.output-two }}" + - uses: Arbeidstilsynet/action-check-changes@v1 + id: changes + with: + # can be space separated or multiline + include-paths: "apps/web .github/workflows/deploy.yml" + exclude-paths: | + **/README.md + apps/web/docs/ + + deploy: + needs: check + if: needs.check.outputs.changed == 'true' + runs-on: ubuntu-latest + steps: + - run: echo "insert deploy here" ``` diff --git a/action.yml b/action.yml index 25433ef..4c47bf3 100644 --- a/action.yml +++ b/action.yml @@ -1,32 +1,145 @@ -name: "No-op Action" +name: "Check changes" author: "Arbeidstilsynet" -description: "A no-op GitHub Action that echoes inputs and sets outputs." +description: "Check if specified paths changed since last successful run of a workflow" inputs: - input-one: - description: "First input value" + workflow-file: + description: Workflow file (e.g. deploy.yml) whose last successful run determines the base commit + required: false + include-paths: + description: Whitespace/newline separated list of Git pathspecs to include required: true - input-two: - description: "Second input value" + exclude-paths: + description: Whitespace/newline separated list of Git pathspecs to exclude required: false - default: "default-value" + default: "" outputs: - output-one: - description: "Echo of input-one" - value: ${{ steps.noop.outputs.output-one }} - output-two: - description: "Echo of input-two" - value: ${{ steps.noop.outputs.output-two }} + changed: + description: "true if any included (and not excluded) paths changed" + value: ${{ steps.diff.outputs.changed }} + base_sha: + description: Base commit used for diff + value: ${{ steps.base.outputs.base_sha }} + head_sha: + description: Current HEAD sha + value: ${{ steps.base.outputs.head_sha }} + changed_files: + description: Newline separated list of changed files after exclusions + value: ${{ steps.diff.outputs.changed_files }} runs: - using: "composite" + using: composite steps: - - name: Echo inputs and set outputs - id: noop + - name: Determine base (last successful run) + id: base shell: bash + env: + GH_TOKEN: ${{ github.token }} run: | - echo "input-one: ${{ inputs.input-one }}" - echo "input-two: ${{ inputs.input-two }}" - echo "output-one=${{ inputs.input-one }}" >> $GITHUB_OUTPUT - echo "output-two=${{ inputs.input-two }}" >> $GITHUB_OUTPUT + set -euo pipefail + + # Prefer explicit input; otherwise derive from GITHUB_WORKFLOW_REF: + # Example GITHUB_WORKFLOW_REF: owner/repo/.github/workflows/test.yml@refs/heads/branch + if [ -n "${{ inputs.workflow-file }}" ]; then + WF_FILE='${{ inputs.workflow-file }}' + echo "Using provided workflow-file input: $WF_FILE" + else + WF_FILE=$(echo "${GITHUB_WORKFLOW_REF:-}" | sed -n 's#.*/\.github/workflows/\([^@]*\)@.*#\1#p') + if [ -n "$WF_FILE" ]; then + echo "Auto-detected workflow file: $WF_FILE" + else + echo "Could not auto-detect workflow file (GITHUB_WORKFLOW_REF='${GITHUB_WORKFLOW_REF:-}'). Will skip API lookup." + fi + fi + + BRANCH="${{ github.ref_name }}" + BASE_SHA="" + HEAD_SHA=$(git rev-parse HEAD) + + if [ -n "$WF_FILE" ]; then + echo "Locating last successful run for $WF_FILE on branch $BRANCH" + JSON=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ + -f branch="$BRANCH" -f status=completed -F per_page=20 2>/dev/null || echo '{}') + + LAST_SUCCESS=$(echo "$JSON" | jq -r ' + (.workflow_runs? // []) + | map(select(.conclusion=="success")) | .[0].head_sha // empty') + + if [ -n "$LAST_SUCCESS" ]; then + BASE_SHA="$LAST_SUCCESS" + fi + else + echo "Skipping workflow run lookup (no workflow file)." + fi + + if [ -z "$BASE_SHA" ]; then + echo "No previous successful run found; falling back to root commit." + BASE_SHA=$(git rev-list --max-parents=0 HEAD) + fi + + echo "Base SHA: $BASE_SHA" + echo "Head SHA: $HEAD_SHA" + + { + echo "base_sha=$BASE_SHA" + echo "head_sha=$HEAD_SHA" + } >> "$GITHUB_OUTPUT" + + - name: Compute diff + id: diff + shell: bash + run: | + set -euo pipefail + BASE_SHA='${{ steps.base.outputs.base_sha }}' + HEAD_SHA='${{ steps.base.outputs.head_sha }}' + INCLUDE_RAW='${{ inputs.include-paths }}' + EXCLUDE_RAW='${{ inputs.exclude-paths }}' + + if [ -z "$INCLUDE_RAW" ]; then + echo "No include paths provided" >&2 + exit 1 + fi + + norm_list () { + printf "%s" "$1" | tr ' \t' '\n' | sed '/^$/d' | sort -u + } + + mapfile -t INCLUDES < <(norm_list "$INCLUDE_RAW") + mapfile -t EXCLUDES < <(norm_list "$EXCLUDE_RAW") + + echo "Include patterns:" + printf ' %s\n' "${INCLUDES[@]}" + if [ ${#EXCLUDES[@]} -gt 0 ]; then + echo "Exclude patterns:" + printf ' %s\n' "${EXCLUDES[@]}" + else + echo "No exclude patterns." + fi + + EXCLUDE_SPEC=() + for p in "${EXCLUDES[@]}"; do + EXCLUDE_SPEC+=(":(exclude)$p") + done + + git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- "${INCLUDES[@]}" "${EXCLUDE_SPEC[@]}" > /tmp/changed_files || true + + if [ -s /tmp/changed_files ]; then + CHANGED=true + else + if git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- "${INCLUDES[@]}" "${EXCLUDE_SPEC[@]}"; then + CHANGED=false + else + CHANGED=true + fi + fi + + echo "Changed: $CHANGED" + cat /tmp/changed_files || true + + { + echo "changed=$CHANGED" + printf "changed_files=" + awk '{printf "%s%s", NR==1?"":"%0A", $0}' /tmp/changed_files + echo + } >> "$GITHUB_OUTPUT" From 1f75c782ae78bfb681175a96d9b6c360d45b0f90 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 14:47:40 +0200 Subject: [PATCH 02/29] test --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3f4330..be65497 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,9 +19,8 @@ jobs: with: include-paths: "." exclude-paths: | - ^docs/ - ^\.github/workflows/ - ^README\.md$ + .github/workflows/ + README.md - run: | echo "Changed: ${{ steps.changes.outputs.changed }}" From dcae7820f46e07015ee9d65e1b18d771d0b8cf0a Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 14:59:04 +0200 Subject: [PATCH 03/29] remove space support --- .github/workflows/test.yml | 3 ++- README.md | 9 +++++---- action.yml | 12 +++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be65497..0d79557 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,8 @@ jobs: - uses: "./" id: changes with: - include-paths: "." + include-paths: | + . exclude-paths: | .github/workflows/ README.md diff --git a/README.md b/README.md index e8e1ea7..43caa50 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ The job must have permission for `actions: read` for the action to retrieve run | Name | Required | Default | Description | |-----------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `workflow-file` | No | (auto-detect) | Workflow filename whose last successful run determines the base commit. If omitted, auto-detected from `GITHUB_WORKFLOW_REF`; if none found falls back to repo root commit. | -| `include-paths` | Yes | — | Whitespace/newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | -| `exclude-paths` | No | (empty) | Whitespace/newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | +| `include-paths` | Yes | — | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | +| `exclude-paths` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | ## Outputs @@ -57,8 +57,9 @@ jobs: - uses: Arbeidstilsynet/action-check-changes@v1 id: changes with: - # can be space separated or multiline - include-paths: "apps/web .github/workflows/deploy.yml" + include-paths: | + apps/web + .github/workflows/deploy.yml exclude-paths: | **/README.md apps/web/docs/ diff --git a/action.yml b/action.yml index 4c47bf3..dc12f10 100644 --- a/action.yml +++ b/action.yml @@ -7,10 +7,10 @@ inputs: description: Workflow file (e.g. deploy.yml) whose last successful run determines the base commit required: false include-paths: - description: Whitespace/newline separated list of Git pathspecs to include + description: Newline separated list of Git pathspecs to include required: true exclude-paths: - description: Whitespace/newline separated list of Git pathspecs to exclude + description: Newline separated list of Git pathspecs to exclude required: false default: "" @@ -101,12 +101,14 @@ runs: exit 1 fi + # New: only split on newlines so patterns may contain spaces. norm_list () { - printf "%s" "$1" | tr ' \t' '\n' | sed '/^$/d' | sort -u + # Read stdin, trim leading/trailing whitespace, drop empty lines, dedupe. + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' | sort -u } - mapfile -t INCLUDES < <(norm_list "$INCLUDE_RAW") - mapfile -t EXCLUDES < <(norm_list "$EXCLUDE_RAW") + mapfile -t INCLUDES < <(printf "%s\n" "$INCLUDE_RAW" | norm_list) + mapfile -t EXCLUDES < <(printf "%s\n" "$EXCLUDE_RAW" | norm_list) echo "Include patterns:" printf ' %s\n' "${INCLUDES[@]}" From 058b756c6df3531bcdd202e571badcd3cfabca2f Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 15:07:49 +0200 Subject: [PATCH 04/29] test2 --- .github/workflows/test.yml | 3 +++ action.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d79557..62d17d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,9 @@ jobs: check: runs-on: ubuntu-latest timeout-minutes: 10 + permissions: + contents: read + actions: read outputs: changes: ${{ steps.changes.outputs.changed }} steps: diff --git a/action.yml b/action.yml index dc12f10..006a5ce 100644 --- a/action.yml +++ b/action.yml @@ -60,7 +60,7 @@ runs: if [ -n "$WF_FILE" ]; then echo "Locating last successful run for $WF_FILE on branch $BRANCH" JSON=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ - -f branch="$BRANCH" -f status=completed -F per_page=20 2>/dev/null || echo '{}') + -f branch="$BRANCH" -f status=completed 2>/dev/null || echo '{}') LAST_SUCCESS=$(echo "$JSON" | jq -r ' (.workflow_runs? // []) From 70021799698b7c7547c71b1764fee64fc807c243 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 15:19:49 +0200 Subject: [PATCH 05/29] test3 --- .github/workflows/test.yml | 5 +++-- README.md | 6 ++++-- action.yml | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 62d17d0..8c22e68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: contents: read actions: read outputs: - changes: ${{ steps.changes.outputs.changed }} + changed: ${{ steps.changes.outputs.changed }} steps: - uses: actions/checkout@v5 with: @@ -20,6 +20,7 @@ jobs: - uses: "./" id: changes with: + token: ${{ github.token }} include-paths: | . exclude-paths: | @@ -34,7 +35,7 @@ jobs: deploy: needs: check - if: needs.check.outputs.changes == 'true' + if: needs.check.outputs.changed == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 diff --git a/README.md b/README.md index 43caa50..b69400e 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,10 @@ The job must have permission for `actions: read` for the action to retrieve run | Name | Required | Default | Description | |-----------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `token` | Yes | | GitHub token for API access (Actions:Read) | +| `include-paths` | Yes | | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | +| `exclude-paths` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | | `workflow-file` | No | (auto-detect) | Workflow filename whose last successful run determines the base commit. If omitted, auto-detected from `GITHUB_WORKFLOW_REF`; if none found falls back to repo root commit. | -| `include-paths` | Yes | — | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | -| `exclude-paths` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | ## Outputs @@ -57,6 +58,7 @@ jobs: - uses: Arbeidstilsynet/action-check-changes@v1 id: changes with: + token: ${{ github.token }} include-paths: | apps/web .github/workflows/deploy.yml diff --git a/action.yml b/action.yml index 006a5ce..ddf4229 100644 --- a/action.yml +++ b/action.yml @@ -3,9 +3,9 @@ author: "Arbeidstilsynet" description: "Check if specified paths changed since last successful run of a workflow" inputs: - workflow-file: - description: Workflow file (e.g. deploy.yml) whose last successful run determines the base commit - required: false + token: + description: "GitHub token for API access (Actions:Read)" + required: true include-paths: description: Newline separated list of Git pathspecs to include required: true @@ -13,6 +13,9 @@ inputs: description: Newline separated list of Git pathspecs to exclude required: false default: "" + workflow-file: + description: Workflow file (e.g. deploy.yml) whose last successful run determines the base commit + required: false outputs: changed: @@ -35,7 +38,7 @@ runs: id: base shell: bash env: - GH_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ inputs.token }} run: | set -euo pipefail From ac47b50ae4adbc7733b3d80de6de0e38bc2f7e07 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 15:30:30 +0200 Subject: [PATCH 06/29] test4 --- action.yml | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/action.yml b/action.yml index ddf4229..a42edd5 100644 --- a/action.yml +++ b/action.yml @@ -42,43 +42,45 @@ runs: run: | set -euo pipefail - # Prefer explicit input; otherwise derive from GITHUB_WORKFLOW_REF: - # Example GITHUB_WORKFLOW_REF: owner/repo/.github/workflows/test.yml@refs/heads/branch + # Resolve workflow file (input or auto-detect) if [ -n "${{ inputs.workflow-file }}" ]; then WF_FILE='${{ inputs.workflow-file }}' - echo "Using provided workflow-file input: $WF_FILE" else WF_FILE=$(echo "${GITHUB_WORKFLOW_REF:-}" | sed -n 's#.*/\.github/workflows/\([^@]*\)@.*#\1#p') - if [ -n "$WF_FILE" ]; then - echo "Auto-detected workflow file: $WF_FILE" - else - echo "Could not auto-detect workflow file (GITHUB_WORKFLOW_REF='${GITHUB_WORKFLOW_REF:-}'). Will skip API lookup." - fi fi - BRANCH="${{ github.ref_name }}" - BASE_SHA="" - HEAD_SHA=$(git rev-parse HEAD) - if [ -n "$WF_FILE" ]; then - echo "Locating last successful run for $WF_FILE on branch $BRANCH" - JSON=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ - -f branch="$BRANCH" -f status=completed 2>/dev/null || echo '{}') - - LAST_SUCCESS=$(echo "$JSON" | jq -r ' - (.workflow_runs? // []) - | map(select(.conclusion=="success")) | .[0].head_sha // empty') + echo "Workflow file: $WF_FILE" + else + echo "No workflow file name available (cannot query runs)." + fi - if [ -n "$LAST_SUCCESS" ]; then - BASE_SHA="$LAST_SUCCESS" + BRANCH='${{ github.ref_name }}' + HEAD_SHA=$(git rev-parse HEAD) + BASE_SHA="" + LAST_SUCCESS="" + + if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then + echo "Fetching workflow runs (branch=$BRANCH)..." + # Keep branch filter so we only look at this branch + WORKFLOW_RUNS=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ + -f branch="$BRANCH" 2>/dev/null || echo "") + if [ -z "$WORKFLOW_RUNS" ]; then + echo "No workflow runs found (first run, permission issue, or filename mismatch)." + else + echo "Found workflow runs, filtering successful ones..." + LAST_SUCCESS=$(echo "$WORKFLOW_RUNS" | jq -r '.workflow_runs[] | select(.conclusion=="success") | .head_sha' | head -n 1 || echo "") + echo "Last successful commit SHA: ${LAST_SUCCESS:-none}" fi else - echo "Skipping workflow run lookup (no workflow file)." + echo "Skipping API lookup (missing workflow file or gh CLI)." fi - if [ -z "$BASE_SHA" ]; then - echo "No previous successful run found; falling back to root commit." + if [ -z "$LAST_SUCCESS" ]; then + echo "No previous successful run; using first commit as base." BASE_SHA=$(git rev-list --max-parents=0 HEAD) + else + BASE_SHA="$LAST_SUCCESS" fi echo "Base SHA: $BASE_SHA" From 1b2a73a1caf4573e8c2a4a32e1eea30c21e4a6e6 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 15:49:28 +0200 Subject: [PATCH 07/29] test5 --- .github/workflows/test2.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/test2.yml diff --git a/.github/workflows/test2.yml b/.github/workflows/test2.yml new file mode 100644 index 0000000..17e97ad --- /dev/null +++ b/.github/workflows/test2.yml @@ -0,0 +1,43 @@ +on: + push: + branches: + - feat/never-ran-this-before + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + actions: read + outputs: + changed: ${{ steps.changes.outputs.changed }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: "./" + id: changes + with: + token: ${{ github.token }} + include-paths: | + . + exclude-paths: | + .github/workflows/ + README.md + + - run: | + echo "Changed: ${{ steps.changes.outputs.changed }}" + echo "Base SHA: ${{ steps.changes.outputs.base_sha }}" + echo "Head SHA: ${{ steps.changes.outputs.head_sha }}" + echo "Changed files: ${{ steps.changes.outputs.changed_files }}" + + deploy: + needs: check + if: needs.check.outputs.changed == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - run: echo "insert deploy here" From 8de8a9b115b728eb084a93756bb69c7e220b760d Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:02:39 +0200 Subject: [PATCH 08/29] test6 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a42edd5..b225bad 100644 --- a/action.yml +++ b/action.yml @@ -38,7 +38,7 @@ runs: id: base shell: bash env: - GITHUB_TOKEN: ${{ inputs.token }} + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail From 634835538d051e42466894d2d769ee096a0c9e47 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:03:35 +0200 Subject: [PATCH 09/29] test7 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b225bad..1d07dd6 100644 --- a/action.yml +++ b/action.yml @@ -38,7 +38,7 @@ runs: id: base shell: bash env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ inputs.token }} run: | set -euo pipefail From f70c0a2b4d4ecd50ffc9de33e3797e0655b6cdfb Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:13:29 +0200 Subject: [PATCH 10/29] test8 --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 1d07dd6..fa96cc6 100644 --- a/action.yml +++ b/action.yml @@ -65,6 +65,7 @@ runs: # Keep branch filter so we only look at this branch WORKFLOW_RUNS=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ -f branch="$BRANCH" 2>/dev/null || echo "") + echo "Workflow runs JSON: ${WORKFLOW_RUNS:-}" if [ -z "$WORKFLOW_RUNS" ]; then echo "No workflow runs found (first run, permission issue, or filename mismatch)." else From 16818655bcdc0dd8f0cf48fe16300ea21b041e32 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:25:31 +0200 Subject: [PATCH 11/29] test9 --- action.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index fa96cc6..766d334 100644 --- a/action.yml +++ b/action.yml @@ -62,15 +62,25 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." - # Keep branch filter so we only look at this branch - WORKFLOW_RUNS=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" \ - -f branch="$BRANCH" 2>/dev/null || echo "") - echo "Workflow runs JSON: ${WORKFLOW_RUNS:-}" - if [ -z "$WORKFLOW_RUNS" ]; then - echo "No workflow runs found (first run, permission issue, or filename mismatch)." + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f branch="$BRANCH" 2>&1) + RC=$? + if [ $RC -ne 0 ]; then + if echo "$API_OUTPUT" | grep -q '"status": *"404"' || echo "$API_OUTPUT" | grep -qi 'Not Found'; then + echo "Workflow not found (404) - treating as no prior runs." + API_OUTPUT="" + else + echo "gh api failed (exit $RC). Output:" + echo "$API_OUTPUT" + exit 1 + fi + fi + + if [ -z "$API_OUTPUT" ]; then + echo "No workflow runs data." else - echo "Found workflow runs, filtering successful ones..." - LAST_SUCCESS=$(echo "$WORKFLOW_RUNS" | jq -r '.workflow_runs[] | select(.conclusion=="success") | .head_sha' | head -n 1 || echo "") + RUNS=$(echo "$API_OUTPUT" | jq -r '(.workflow_runs? // []) | length' 2>/dev/null || echo 0) + echo "Detected $RUNS run(s)." + LAST_SUCCESS=$(echo "$API_OUTPUT" | jq -r '(.workflow_runs? // []) | map(select(.conclusion=="success")) | .[0].head_sha // empty' 2>/dev/null || echo "") echo "Last successful commit SHA: ${LAST_SUCCESS:-none}" fi else From f1f5de86c78aced006df8b21d23bbfd6c410c431 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:35:18 +0200 Subject: [PATCH 12/29] test10 --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 766d334..9fa4ea8 100644 --- a/action.yml +++ b/action.yml @@ -62,8 +62,12 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." - API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f branch="$BRANCH" 2>&1) + set +euo pipefail # disable -e to handle gh api failures gracefully + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f + branch="$BRANCH" 2>&1) RC=$? + set -euo pipefail + if [ $RC -ne 0 ]; then if echo "$API_OUTPUT" | grep -q '"status": *"404"' || echo "$API_OUTPUT" | grep -qi 'Not Found'; then echo "Workflow not found (404) - treating as no prior runs." From e597a31b436a1e81e35790097c30f0b4f51303f1 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:43:28 +0200 Subject: [PATCH 13/29] test11 --- action.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 9fa4ea8..4654758 100644 --- a/action.yml +++ b/action.yml @@ -62,11 +62,10 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." - set +euo pipefail # disable -e to handle gh api failures gracefully - API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f - branch="$BRANCH" 2>&1) + set +e # handle gh api failures gracefully + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f branch="$BRANCH" 2>&1) RC=$? - set -euo pipefail + set -e if [ $RC -ne 0 ]; then if echo "$API_OUTPUT" | grep -q '"status": *"404"' || echo "$API_OUTPUT" | grep -qi 'Not Found'; then From 7ad38b8be0ca2ae02cbd935075badac6d1db31f3 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:48:59 +0200 Subject: [PATCH 14/29] test12 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4654758..880a66f 100644 --- a/action.yml +++ b/action.yml @@ -63,7 +63,7 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." set +e # handle gh api failures gracefully - API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs" -f branch="$BRANCH" 2>&1) + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs?branch=$BRANCH" 2>&1) RC=$? set -e From 8e6d2eccb49c38346909f82837fc4cc43053d9a0 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:55:21 +0200 Subject: [PATCH 15/29] test13 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c22e68..5150ce8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,7 @@ jobs: exclude-paths: | .github/workflows/ README.md + somefile - run: | echo "Changed: ${{ steps.changes.outputs.changed }}" From 3598c6d8058638805c4532ad3559dc892aea62ad Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 16:58:08 +0200 Subject: [PATCH 16/29] test14 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 880a66f..1460f19 100644 --- a/action.yml +++ b/action.yml @@ -38,7 +38,7 @@ runs: id: base shell: bash env: - GH_TOKEN: ${{ inputs.token }} + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail From 418abb57a7df12e23068cc7268cddbf68e9cb1c3 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 17:03:26 +0200 Subject: [PATCH 17/29] remove token input --- .github/workflows/test.yml | 1 - .github/workflows/test2.yml | 1 - README.md | 2 -- action.yml | 3 --- 4 files changed, 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5150ce8..b6809d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,6 @@ jobs: - uses: "./" id: changes with: - token: ${{ github.token }} include-paths: | . exclude-paths: | diff --git a/.github/workflows/test2.yml b/.github/workflows/test2.yml index 17e97ad..e98e952 100644 --- a/.github/workflows/test2.yml +++ b/.github/workflows/test2.yml @@ -20,7 +20,6 @@ jobs: - uses: "./" id: changes with: - token: ${{ github.token }} include-paths: | . exclude-paths: | diff --git a/README.md b/README.md index b69400e..084606a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ The job must have permission for `actions: read` for the action to retrieve run | Name | Required | Default | Description | |-----------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `token` | Yes | | GitHub token for API access (Actions:Read) | | `include-paths` | Yes | | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | | `exclude-paths` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | | `workflow-file` | No | (auto-detect) | Workflow filename whose last successful run determines the base commit. If omitted, auto-detected from `GITHUB_WORKFLOW_REF`; if none found falls back to repo root commit. | @@ -58,7 +57,6 @@ jobs: - uses: Arbeidstilsynet/action-check-changes@v1 id: changes with: - token: ${{ github.token }} include-paths: | apps/web .github/workflows/deploy.yml diff --git a/action.yml b/action.yml index 1460f19..6860685 100644 --- a/action.yml +++ b/action.yml @@ -3,9 +3,6 @@ author: "Arbeidstilsynet" description: "Check if specified paths changed since last successful run of a workflow" inputs: - token: - description: "GitHub token for API access (Actions:Read)" - required: true include-paths: description: Newline separated list of Git pathspecs to include required: true From 0a41e6d4ffe000745c04760811d1e00bbf6157f7 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 17:07:57 +0200 Subject: [PATCH 18/29] simplify --- action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 6860685..2c7bba8 100644 --- a/action.yml +++ b/action.yml @@ -145,11 +145,7 @@ runs: if [ -s /tmp/changed_files ]; then CHANGED=true else - if git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- "${INCLUDES[@]}" "${EXCLUDE_SPEC[@]}"; then - CHANGED=false - else - CHANGED=true - fi + CHANGED=false fi echo "Changed: $CHANGED" From aebddaf35b49cd1c42cdb089819c6b5c027a12b1 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 17:09:03 +0200 Subject: [PATCH 19/29] test fail --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index 2c7bba8..f761066 100644 --- a/action.yml +++ b/action.yml @@ -39,6 +39,8 @@ runs: run: | set -euo pipefail + exit 1 # TEMP FAIL + # Resolve workflow file (input or auto-detect) if [ -n "${{ inputs.workflow-file }}" ]; then WF_FILE='${{ inputs.workflow-file }}' From 0c66179d0271781b3618cca8c327117ab1741e57 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Tue, 16 Sep 2025 17:09:29 +0200 Subject: [PATCH 20/29] undo test fail --- action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yml b/action.yml index f761066..2c7bba8 100644 --- a/action.yml +++ b/action.yml @@ -39,8 +39,6 @@ runs: run: | set -euo pipefail - exit 1 # TEMP FAIL - # Resolve workflow file (input or auto-detect) if [ -n "${{ inputs.workflow-file }}" ]; then WF_FILE='${{ inputs.workflow-file }}' From 44d3e6f6f4b9bab097d7e4739ceefb0af038fb0a Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 12:44:43 +0200 Subject: [PATCH 21/29] update output variable name from 'changed' to 'changes_detected' in workflows and documentation --- .github/workflows/test.yml | 2 +- .github/workflows/test2.yml | 2 +- README.md | 14 +++++++------- action.yml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6809d6..8dc61eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: somefile - run: | - echo "Changed: ${{ steps.changes.outputs.changed }}" + echo "Changed: ${{ steps.changes.outputs.changes_detected }}" echo "Base SHA: ${{ steps.changes.outputs.base_sha }}" echo "Head SHA: ${{ steps.changes.outputs.head_sha }}" echo "Changed files: ${{ steps.changes.outputs.changed_files }}" diff --git a/.github/workflows/test2.yml b/.github/workflows/test2.yml index e98e952..e6a895d 100644 --- a/.github/workflows/test2.yml +++ b/.github/workflows/test2.yml @@ -27,7 +27,7 @@ jobs: README.md - run: | - echo "Changed: ${{ steps.changes.outputs.changed }}" + echo "Changed: ${{ steps.changes.outputs.changes_detected }}" echo "Base SHA: ${{ steps.changes.outputs.base_sha }}" echo "Head SHA: ${{ steps.changes.outputs.head_sha }}" echo "Changed files: ${{ steps.changes.outputs.changed_files }}" diff --git a/README.md b/README.md index 084606a..77ec652 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,12 @@ The job must have permission for `actions: read` for the action to retrieve run ## Outputs -| Name | Description | -|-----------------|-------------------------------------------------------------------------------------------------------| -| `changed` | `true` if any included (and not excluded) paths changed between base and head. | -| `base_sha` | The base commit SHA used for the diff (last successful run’s head, or fallback). | -| `head_sha` | The current commit SHA. | -| `changed_files` | Newline separated list of changed files after exclusions. URL-escaped newlines in raw output context. | +| Name | Description | +|--------------------|-------------------------------------------------------------------------------------------------------| +| `changes_detected` | `true` if any included (and not excluded) paths changed between base and head. | +| `base_sha` | The base commit SHA used for the diff (last successful run’s head, or fallback). | +| `head_sha` | The current commit SHA. | +| `changed_files` | Newline separated list of changed files after exclusions. URL-escaped newlines in raw output context. | ## Usage @@ -48,7 +48,7 @@ jobs: contents: read actions: read outputs: - changed: ${{ steps.changes.outputs.changed }} + changed: ${{ steps.changes.outputs.changes_detected }} steps: - uses: actions/checkout@v5 with: diff --git a/action.yml b/action.yml index 2c7bba8..2d0a30a 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: required: false outputs: - changed: + changes_detected: description: "true if any included (and not excluded) paths changed" value: ${{ steps.diff.outputs.changed }} base_sha: From 79a7a016d55fbbc793832d976c70a60d3f97ca93 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:05:05 +0200 Subject: [PATCH 22/29] test2 update --- .github/workflows/test2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test2.yml b/.github/workflows/test2.yml index e6a895d..060b416 100644 --- a/.github/workflows/test2.yml +++ b/.github/workflows/test2.yml @@ -17,7 +17,7 @@ jobs: with: fetch-depth: 0 - - uses: "./" + - uses: "Arbeidstilsynet/action-check-changes@feat/add-action" id: changes with: include-paths: | @@ -27,7 +27,7 @@ jobs: README.md - run: | - echo "Changed: ${{ steps.changes.outputs.changes_detected }}" + echo "Changed: ${{ steps.changes.outputs.changed_files }}" echo "Base SHA: ${{ steps.changes.outputs.base_sha }}" echo "Head SHA: ${{ steps.changes.outputs.head_sha }}" echo "Changed files: ${{ steps.changes.outputs.changed_files }}" From a532502c922fb9553bc82f4e59a78259aee7d4c2 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:08:42 +0200 Subject: [PATCH 23/29] provoke api error --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2d0a30a..603be63 100644 --- a/action.yml +++ b/action.yml @@ -60,7 +60,7 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." set +e # handle gh api failures gracefully - API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs?branch=$BRANCH" 2>&1) + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs?branch=${BRANCH}2" 2>&1) RC=$? set -e From 6540016cc0e25b82afe28fd335ba55daf317dc6a Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:13:56 +0200 Subject: [PATCH 24/29] fix test --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8dc61eb..f20b9ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,10 +20,9 @@ jobs: - uses: "./" id: changes with: - include-paths: | - . + include-paths: .github/workflows/ exclude-paths: | - .github/workflows/ + .github/workflows/test2.yml README.md somefile @@ -35,7 +34,7 @@ jobs: deploy: needs: check - if: needs.check.outputs.changed == 'true' + if: needs.check.outputs.changes_detected == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 From 7c8cb27037cfd90718c3581d94aa00c6271df083 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:15:30 +0200 Subject: [PATCH 25/29] echo RC --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 603be63..8ee3edd 100644 --- a/action.yml +++ b/action.yml @@ -64,6 +64,9 @@ runs: RC=$? set -e + echo "RC=$RC" + echo "API_OUTPUT=$API_OUTPUT" + if [ $RC -ne 0 ]; then if echo "$API_OUTPUT" | grep -q '"status": *"404"' || echo "$API_OUTPUT" | grep -qi 'Not Found'; then echo "Workflow not found (404) - treating as no prior runs." From f4709c8121a066281ea0ef315e0a3a9777c27c5f Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:18:23 +0200 Subject: [PATCH 26/29] provoke api error? --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8ee3edd..3ee159b 100644 --- a/action.yml +++ b/action.yml @@ -60,7 +60,7 @@ runs: if [ -n "$WF_FILE" ] && command -v gh >/dev/null 2>&1; then echo "Fetching workflow runs (branch=$BRANCH)..." set +e # handle gh api failures gracefully - API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}/runs?branch=${BRANCH}2" 2>&1) + API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}2/runs?branch=${BRANCH}" 2>&1) RC=$? set -e From 0a33b59e080ca26e03091105dd16f1511a0be4d0 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:23:55 +0200 Subject: [PATCH 27/29] remove debug --- action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 3ee159b..28569bf 100644 --- a/action.yml +++ b/action.yml @@ -62,10 +62,8 @@ runs: set +e # handle gh api failures gracefully API_OUTPUT=$(gh api "repos/${{ github.repository }}/actions/workflows/${WF_FILE}2/runs?branch=${BRANCH}" 2>&1) RC=$? - set -e - echo "RC=$RC" - echo "API_OUTPUT=$API_OUTPUT" + set -e if [ $RC -ne 0 ]; then if echo "$API_OUTPUT" | grep -q '"status": *"404"' || echo "$API_OUTPUT" | grep -qi 'Not Found'; then From 81ef0a6211843453de938cf1fc6042717181f5a2 Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:26:34 +0200 Subject: [PATCH 28/29] rename include/exclude --- .github/workflows/test.yml | 5 +++-- .github/workflows/test2.yml | 4 ++-- README.md | 4 ++-- action.yml | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f20b9ea..fb6b027 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,8 +20,9 @@ jobs: - uses: "./" id: changes with: - include-paths: .github/workflows/ - exclude-paths: | + workflow-file: "main.yml" + include: .github/workflows/ + exclude: | .github/workflows/test2.yml README.md somefile diff --git a/.github/workflows/test2.yml b/.github/workflows/test2.yml index 060b416..bf77c58 100644 --- a/.github/workflows/test2.yml +++ b/.github/workflows/test2.yml @@ -20,9 +20,9 @@ jobs: - uses: "Arbeidstilsynet/action-check-changes@feat/add-action" id: changes with: - include-paths: | + include: | . - exclude-paths: | + exclude: | .github/workflows/ README.md diff --git a/README.md b/README.md index 77ec652..6881d5a 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ The job must have permission for `actions: read` for the action to retrieve run | Name | Required | Default | Description | |-----------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `include-paths` | Yes | | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | -| `exclude-paths` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | +| `include` | Yes | | Newline separated Git pathspecs (globs) to include in the diff scope (e.g. `src/`, `app/**/*.ts`). | +| `exclude` | No | (empty) | Newline separated Git pathspecs to exclude. Each is applied as `:(exclude)`. | | `workflow-file` | No | (auto-detect) | Workflow filename whose last successful run determines the base commit. If omitted, auto-detected from `GITHUB_WORKFLOW_REF`; if none found falls back to repo root commit. | ## Outputs diff --git a/action.yml b/action.yml index 28569bf..794d3a6 100644 --- a/action.yml +++ b/action.yml @@ -3,10 +3,10 @@ author: "Arbeidstilsynet" description: "Check if specified paths changed since last successful run of a workflow" inputs: - include-paths: + include: description: Newline separated list of Git pathspecs to include required: true - exclude-paths: + exclude: description: Newline separated list of Git pathspecs to exclude required: false default: "" @@ -110,8 +110,8 @@ runs: set -euo pipefail BASE_SHA='${{ steps.base.outputs.base_sha }}' HEAD_SHA='${{ steps.base.outputs.head_sha }}' - INCLUDE_RAW='${{ inputs.include-paths }}' - EXCLUDE_RAW='${{ inputs.exclude-paths }}' + INCLUDE_RAW='${{ inputs.include }}' + EXCLUDE_RAW='${{ inputs.exclude }}' if [ -z "$INCLUDE_RAW" ]; then echo "No include paths provided" >&2 From 3f816f10e8536bb781fad4ffdd8ca06e8659550c Mon Sep 17 00:00:00 2001 From: Grunde Thorheim Date: Wed, 17 Sep 2025 13:27:55 +0200 Subject: [PATCH 29/29] rename fix readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6881d5a..4ef3752 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ jobs: - uses: Arbeidstilsynet/action-check-changes@v1 id: changes with: - include-paths: | + include: | apps/web .github/workflows/deploy.yml - exclude-paths: | + exclude: | **/README.md apps/web/docs/