Skip to content

Commit fdf9ee2

Browse files
Fix PR comment: add permissions and AEM_AUTHOR_URL env for github-script
1 parent d15edab commit fdf9ee2

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/publish-skill-to-aem.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: 'Commit SHA to checkout'
1212
required: true
1313
type: string
14+
pr_number:
15+
description: 'PR number for commenting (optional, omit for merge runs)'
16+
required: false
17+
type: number
1418
secrets:
1519
AEM_USERNAME:
1620
required: true
@@ -158,3 +162,33 @@ jobs:
158162
-d "cmd=Activate" \
159163
-d "path=${cf_path}"
160164
echo "✅ CF replicated"
165+
166+
- name: Comment PR with staging link
167+
if: ${{ inputs.pr_number != 0 }}
168+
uses: actions/github-script@v7
169+
env:
170+
AEM_AUTHOR_URL: ${{ secrets.AEM_AUTHOR_URL }}
171+
with:
172+
script: |
173+
const skillName = '${{ inputs.skill_name }}';
174+
const cfPath = '/content/dam/snowflake-site/en/content-fragments/skills-library/' + skillName;
175+
const authorUrl = process.env.AEM_AUTHOR_URL;
176+
const cfLink = `${authorUrl}/ui#/aem/editor.html${cfPath}`;
177+
178+
const body = `## ✅ Skill Staged to AEM
179+
180+
**Skill:** \`${skillName}\`
181+
182+
👉 **AEM Staging CF:** [Open in AEM Author](${cfLink})
183+
184+
> Content Fragment has been created/updated and replicated to the staging publish instance.
185+
186+
---
187+
*Generated by GitHub Actions*`;
188+
189+
await github.rest.issues.createComment({
190+
owner: context.repo.owner,
191+
repo: context.repo.repo,
192+
issue_number: ${{ inputs.pr_number }},
193+
body
194+
});

.github/workflows/stage-skills-on-pr.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
jobs:
1010
detect_changes:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
issues: write
15+
pull-requests: write
1216
outputs:
1317
skills_json: ${{ steps.detect.outputs.skills_json }}
1418
has_changes: ${{ steps.detect.outputs.has_changes }}
@@ -56,6 +60,7 @@ jobs:
5660
with:
5761
skill_name: ${{ matrix.skill.name }}
5862
commit_sha: ${{ github.event.pull_request.head.sha }}
63+
pr_number: ${{ github.event.pull_request.number }}
5964
secrets:
6065
AEM_USERNAME: ${{ secrets.AEM_USERNAME_STAGING }}
6166
AEM_PASSWORD: ${{ secrets.AEM_PASSWORD_STAGING }}

0 commit comments

Comments
 (0)