-
Notifications
You must be signed in to change notification settings - Fork 107
45 lines (37 loc) · 1.4 KB
/
version_update_trigger.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Version trigger workflow
on:
pull_request:
jobs:
build:
runs-on: [self-hosted, k8s-runner]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Fetch the pull request diff
run: git fetch origin ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
- name: Check if a particular file has changed
id: check_file
run: |
# Check if 'package.json' has changed in the PR
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q 'package.json'; then
echo "file_changed=true" >> $GITHUB_ENV
else
echo "file_changed=false" >> $GITHUB_ENV
fi
- name: Take action based on file change
if: env.file_changed == 'true'
run: |
echo "version_line=$(grep -m 1 "\"version\":" ${GITHUB_WORKSPACE}/package.json)" >> $GITHUB_ENV
- name: Post a comment on the PR
if: env.file_changed == 'true'
uses: actions/github-script@v6
with:
script: |
const pr_number = ${GITHUB_REF.split('/')[2]};
const message = "pg-core-sdk-version-update\n$version_line\nSDK: React-Native Standard Checkout SDK";
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
body: message,
})