Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions .github/workflows/on-merge-check.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
name: Pipeline Check
name: Check Package.json Changes

on:
push:
branches-ignore:
- "*"
pull_request:
types:
- synchronize
- opened
- reopened

jobs:
check_pipeline:
runs-on: macos-latest
check_package_json_changes:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Check for changes in package.json
id: check_changes
- name: Get changed files
id: changed_files
run: |
git fetch
git diff --name-only HEAD^ HEAD | grep -E "package\.json$" || echo "::set-output name=changed::false"
echo "::set-output name=changed::true"
echo "::set-output name=changed_files::$(git diff --name-only ${{ github.base_ref }}...${{ github.head_ref }})"

- name: Trigger pipeline check
if: ${{ steps.check_changes.outputs.changed == 'true' }}
- name: Check for package.json changes
id: package_json_changes
run: |
# Perform actions to trigger pipeline check, e.g., API call or running a script
echo "Pipeline check triggered"
CHANGED_FILES="${{ steps.changed_files.outputs.changed_files }}"
if [[ "$CHANGED_FILES" =~ "package.json" ]]; then
echo "::set-output name=package_json_changed::true"
else
echo "::set-output name=package_json_changed::false"
fi

- name: Comment on pull request
if: steps.package_json_changes.outputs.package_json_changed == 'true'
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const context = github.context;
const owner = context.repo.owner;
const repo = context.repo.repo;
const prNumber = context.issue.number;
const commentBody = 'Warning: The `package.json` file has changed in this pull request.';

github.issues.createComment({
owner: owner,
repo: repo,
issue_number: prNumber,
body: commentBody
});