Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH action security updates #264

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Changes from 2 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
107 changes: 55 additions & 52 deletions .github/workflows/add-netlify-links.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
name: Add Netlify Links To Changed Pages
on:
workflow_call:
workflow_call:
pull_request_target:
mongoKart marked this conversation as resolved.
Show resolved Hide resolved
jobs:
get-pr-changes:
name: Get Changed Files & Update PR Description
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
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 }}--mongodb-docs-csharp.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}"
filenoslash="${file:1}"
echo "${base_link}${file}"
new_links+="<li><a href=${base_link}${file}>${filenoslash}</a></li>"
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"
- name: Update the 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${{ steps.build_page_links.outputs.staging_links }}\n<!-- end insert-links -->"
token: ${{ secrets.GITHUB_TOKEN }}
get-pr-changes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all these lines are changed; VS Code changed the indenting. Changes are between lines 18 and 48

name: Get Changed Files & Update PR Description
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
steps:
- uses: actions/checkout@v4
- name: Get Changed Files
id: changed-files
# pin to a specific commit to ensure stability
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
mongoKart marked this conversation as resolved.
Show resolved Hide resolved
with:
separator: ","
files: source/**
- name: Build Netlify Links for Changed Pages
id: build_page_links
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
new_links=""
base_link='https://deploy-preview-${{ github.event.number }}--mongodb-docs-csharp.netlify.app'
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}"
filenoslash="${file:1}"
echo "${base_link}${file}"
new_links+="<li><a href=${base_link}${file}>${filenoslash}</a></li>"
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"
- name: Update the 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${{ steps.build_page_links.outputs.staging_links }}\n<!-- end insert-links -->"
token: ${{ secrets.GITHUB_TOKEN }}
Loading