Skip to content

Commit 9506bce

Browse files
committed
adding github action to main
1 parent b2a01d8 commit 9506bce

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Update Template Files in Submodules
2+
3+
on:
4+
push:
5+
paths:
6+
- 'PR-Template.md'
7+
- 'Bug-Issue-Template.md'
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
update-templates:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
repo:
19+
[
20+
'associations-sync-server',
21+
'crm-object-sync',
22+
'property-mapping-client',
23+
'property-mapping-server'
24+
]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Check for template changes
31+
id: check_files
32+
run: |
33+
PR_TEMPLATE_UPDATED=false
34+
BUG_TEMPLATE_UPDATED=false
35+
36+
git fetch origin
37+
38+
if git diff --name-only HEAD^ HEAD | grep -q "PR-Template.md"; then
39+
PR_TEMPLATE_UPDATED=true
40+
fi
41+
42+
if git diff --name-only HEAD^ HEAD | grep -q "Bug-Issue-Template.md"; then
43+
BUG_TEMPLATE_UPDATED=true
44+
fi
45+
46+
echo "pr_updated=$PR_TEMPLATE_UPDATED" >> $GITHUB_OUTPUT
47+
echo "bug_updated=$BUG_TEMPLATE_UPDATED" >> $GITHUB_OUTPUT
48+
49+
- name: Create repository dispatch event
50+
if: steps.check_files.outputs.pr_updated == 'true' || steps.check_files.outputs.bug_updated == 'true'
51+
uses: peter-evans/repository-dispatch@v3
52+
with:
53+
token: ${{ secrets.GH_PAT }}
54+
repository: hubspotdev/${{ matrix.repo }}
55+
event-type: update-templates
56+
client-payload: |
57+
{
58+
"pr_template_updated": "${{ steps.check_files.outputs.pr_updated }}",
59+
"bug_template_updated": "${{ steps.check_files.outputs.bug_updated }}",
60+
"pr_template_content": "${{ steps.check_files.outputs.pr_updated == 'true' && 'true' || 'false' }}",
61+
"bug_template_content": "${{ steps.check_files.outputs.bug_updated == 'true' && 'true' || 'false' }}",
62+
"source_repo": "CODE-Hub"
63+
}
64+
65+
- name: Upload PR Template content
66+
if: steps.check_files.outputs.pr_updated == 'true'
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: pr-template-${{ matrix.repo }}
70+
path: PR-Template.md
71+
retention-days: 1
72+
73+
- name: Upload Bug Template content
74+
if: steps.check_files.outputs.bug_updated == 'true'
75+
uses: actions/upload-artifact@v3
76+
with:
77+
name: bug-template-${{ matrix.repo }}
78+
path: Bug-Issue-Template.md
79+
retention-days: 1

0 commit comments

Comments
 (0)