Skip to content

Commit

Permalink
Merge branch 'mwong-add-preview-link' into test-preview-link-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Sep 20, 2024
2 parents ac7a710 + 99f4176 commit 1675b99
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/preview-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,34 @@ jobs:
echo "No changed files found in the specified directories."
LINKS="- No documentation files were changed."
else
LINKS=$(echo "$CHANGED_FILES" | sed 's#website/docs/docs/##; s/.md$//' | awk -v url="$DEPLOYMENT_URL" '{print "- [" $0 "](" url "/docs/" $0 ")"}')
LINKS=""
for FILE in $CHANGED_FILES; do
# Remove 'website/docs/' prefix and '.md' extension
FILE_PATH="${FILE#website/docs/}"
FILE_PATH="${FILE_PATH%.md}"
# Replace spaces and special characters with hyphens in URL path
URL_PATH=$(echo "$FILE_PATH" | sed 's/ /-/g; s/[^a-zA-Z0-9\-_\/]//g' | tr '[:upper:]' '[:lower:]')
FULL_URL="$DEPLOYMENT_URL/$URL_PATH"
LINKS="$LINKS\n- [$FULL_URL]($FULL_URL)"
done
fi
echo "links=$LINKS" >> $GITHUB_OUTPUT
# Output the links
echo -e "links=$LINKS" >> $GITHUB_OUTPUT
- name: Post comment with deployment link
uses: peter-evans/create-or-update-comment@v4
uses: actions/github-script@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { github, context } = require('@actions/github');
const issue_number = context.payload.pull_request.number;
const body = `
🚀 Deployment available! Here are the direct links to the updated files:
${{ steps.links.outputs.links }}
`;
await github.rest.issues.createComment({
...context.repo,
issue_number,
body: body
});

0 comments on commit 1675b99

Please sign in to comment.