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
21 changes: 19 additions & 2 deletions .github/workflows/build-site-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,33 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event.pull_request.head.repo.fork && github.sha || github.head_ref }}

- name: Build Site Metadata
run: npx --yes github:AdobeDocs/adp-devsite-utils buildSiteMetadata -v

- name: Check for changes
id: check_changes
run: |
if git diff --quiet HEAD -- src/pages/adp-site-metadata.json; then
echo "No changes to commit, skipping commit and push"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Recommend building metadata locally
if: github.event.pull_request.head.repo.fork == true && steps.check_changes.outputs.changed == 'true'
run: |
echo "::error::This PR is from a fork. Please run 'npm run buildSiteMetadata' locally and commit the updated src/pages/adp-site-metadata.json file."
exit 1

- name: Commit and push if changed
if: steps.check_changes.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/pages/adp-site-metadata.json
git diff --cached --quiet || git commit -m "Generate site metadata"
git commit -m "Generate site metadata"
git pull --rebase
git push