Skip to content

Commit 4aff9c4

Browse files
Merge pull request #2 from bencgreenberg/update-action-example
Update action example
2 parents d1bbbcf + 7612e64 commit 4aff9c4

File tree

813 files changed

+32
-2149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

813 files changed

+32
-2149
lines changed

docs/review_markdown.yml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,56 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v2
1515

16-
- name: Get the latest release URL
17-
id: get_latest_release
18-
uses: actions/github-script@v5
19-
with:
20-
script: |
21-
const response = await github.rest.repos.getLatestRelease({
22-
owner: 'bencgreenberg',
23-
repo: 'github-action-gpt-language-check'
24-
});
25-
const asset = response.data.assets.find(asset => asset.name === 'github-action-gpt-language-check');
26-
if (!asset) {
27-
throw new Error('Binary not found in the latest release');
28-
}
29-
return { url: asset.browser_download_url };
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
33-
3416
- name: Download pre-built Rust script from remote repository
3517
run: |
36-
wget "${{ steps.get_latest_release.outputs.url }}" -O github-action-gpt-language-check
18+
# Fetch the latest release information from the GitHub API
19+
release_info=$(curl -s -H "Accept: application/vnd.github+json" https://api.github.com/repos/bencgreenberg/github-action-gpt-language-check/releases/latest)
20+
21+
# Extract the binary's download URL using 'jq'
22+
binary_url=$(echo $release_info | jq -r '.assets[] | select(.name == "github-action-gpt-language-check") | .browser_download_url')
23+
24+
# Download the binary using 'wget'
25+
wget "$binary_url" -O github-action-gpt-language-check
26+
27+
# Make the binary executable
3728
chmod +x github-action-gpt-language-check
29+
shell: bash
3830

3931
- name: Run Rust script for each markdown file
4032
env:
4133
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
4234
run: |
4335
suggestions=""
44-
for file in $(find . -type f -iname "*.md"); do
45-
echo "Reviewing: $file"
46-
suggestion=$(./github-action-gpt-language-check "$file")
47-
if [[ ! -z "$suggestion" ]]; then
48-
suggestions+="- $file: $suggestion\n"
49-
echo "Suggestion found"
50-
echo "SUGGESTION_FOUND=true" >> $GITHUB_ENV
36+
pr_files=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.number }}/files | jq -r '.[].filename')
37+
for file in $pr_files; do
38+
if [[ $file == *.md ]]; then
39+
echo "Reviewing: $file"
40+
suggestion=$(./github-action-gpt-language-check "$file")
41+
if [[ ! -z "$suggestion" ]]; then
42+
suggestions+="- $file: $suggestion\n"
43+
echo "Suggestion found"
44+
echo "SUGGESTION_FOUND=true" >> $GITHUB_ENV
45+
fi
5146
fi
5247
done
53-
echo "SUGGESTIONS=$suggestions" >> $GITHUB_ENV
54-
55-
48+
# Use printf to set SUGGESTIONS environment variable
49+
printf 'SUGGESTIONS<<EOF\n%s\nEOF' "$suggestions" >> $GITHUB_ENV
5650
5751
- name: Add a comment to the pull request
5852
if: ${{ env.SUGGESTION_FOUND == 'true' }}
5953
uses: actions/github-script@v5
6054
with:
6155
script: |
62-
const suggestions = `Suggested changes: ${process.env.SUGGESTIONS}`
56+
const suggestionsList = process.env.SUGGESTIONS.split('\n').filter(suggestion => suggestion.trim() !== '');
57+
let suggestionsMarkdown = '## Suggested Changes\n';
58+
for (const suggestion of suggestionsList) {
59+
const [file, ...suggestionText] = suggestion.split(':');
60+
suggestionsMarkdown += `### Reviewed File: **${file.trim()}**\n\n`;
61+
suggestionsMarkdown += `- ${suggestionText.join(':').trim()}\n\n`;
62+
}
6363
github.rest.issues.createComment({
6464
issue_number: context.issue.number,
6565
owner: context.repo.owner,
6666
repo: context.repo.repo,
67-
body: suggestions
68-
});
69-
67+
body: suggestionsMarkdown
68+
});

target/.rustc_info.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

target/CACHEDIR.TAG

Lines changed: 0 additions & 3 deletions
This file was deleted.

target/release/.cargo-lock

Whitespace-only changes.
Binary file not shown.

target/release/.fingerprint/autocfg-40adb2b60f3db129/invoked.timestamp

Lines changed: 0 additions & 1 deletion
This file was deleted.

target/release/.fingerprint/autocfg-40adb2b60f3db129/lib-autocfg

Lines changed: 0 additions & 1 deletion
This file was deleted.

target/release/.fingerprint/autocfg-40adb2b60f3db129/lib-autocfg.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
-8 Bytes
Binary file not shown.

target/release/.fingerprint/base64-3a739617ff3cb95c/invoked.timestamp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)