Skip to content

add test file

add test file #1

name: Add Netlify Links To Changed Pages
on:
workflow_call:
pull_request_target:
jobs:
get-pr-changes:
name: Get Changed Files
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
outputs:
staging_links: ${{ steps.build_page_links.outputs.staging_links }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
separator: ","
files: source/**
- name: Build Netlify Links for Changed Pages
id: build_page_links
run: |
new_links=""
base_link='https://deploy-preview-${{ github.event.number }}--app-services.netlify.app'
changed_files=${{ steps.changed-files.outputs.all_changed_files }}
files=$(echo $changed_files | tr "," "\n")
for file in $files; do
echo "processing ${file}"
if (! grep -s "includes/" <<< $file) &&
(! grep -s "images/" <<< $file) &&
(! grep -s "examples/" <<< $file); then
file="${file#source}"
file="${file%.txt}"
echo "${base_link}${file}"
new_links+="<br/> - ${base_link}${file}"
else
echo "(file skipped)"
fi
done
if [ "$new_links" == "" ]; then
new_links="No pages to preview"
fi
echo "Final new_links string: "
echo "${new_links}"
echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT"
update-pr-description:
name: Update the PR Description
needs: get-pr-changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Debug
id: parser
run: |
echo "${{ needs.get-pr-changes.outputs.staging_links }}"
- name: Update PR Description
uses: MongoCaleb/pr-description-action@master
with:
regex: "<!-- start insert-links -->.*<!-- end insert-links -->"
appendContentOnMatchOnly: true
regexFlags: is
content: "<!-- start insert-links -->\n${{ needs.get-pr-changes.outputs.staging_links }}\n<!-- end insert-links -->"
token: ${{ secrets.GITHUB_TOKEN }}