Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DevIos01 authored Oct 25, 2024
2 parents f8b3132 + 99a1b2b commit 92f9537
Show file tree
Hide file tree
Showing 42 changed files with 2,143 additions and 194 deletions.
13 changes: 12 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ GRAPHITE_HOST=
STUCK_AIRTABLE_BASE=
SENDGRID_API_KEY=
LOOPS_API_KEY=
DEV_CODE=
DEV_CODE=

PUBLIC_SPRIG_LLM_API=
EMAIL_FROM=
EMAIL_REPLY_TO=
PUBLIC_SIGNALING_SERVER_HOST=
GITHUB_CLIENT_SECRET=
PUBLIC_GITHUB_CLIENT_ID=
PUBLIC_GITHUB_REDIRECT_URI=
PUBLIC_GALLERY_API=
MAX_ATTEMPTS=
LOCKOUT_DURATION_MS=
73 changes: 73 additions & 0 deletions .github/workflows/post-vercel-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Sprig Review Preview Links

on:
pull_request:
types: [opened, synchronize]

jobs:
post-vercel-preview-comment:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get list of changed files
id: changed-files
run: |
echo "Pull Request Base SHA: ${{ github.event.pull_request.base.sha }}"
echo "Pull Request Head SHA: ${{ github.event.pull_request.head.sha }}"
js_files=$(git diff --name-only --diff-filter=AM --find-renames --find-copies ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep 'games/.*\.js$' | xargs)
first_js_file=$(basename "$js_files" .js)
if [ -n "$first_js_file" ]; then
echo "FIRST_JS_FILE=$first_js_file" >> $GITHUB_ENV
else
echo "No matching .js files found in games/ directory."
exit 0
fi
- name: Fetch existing comments on the pull request
if: env.FIRST_JS_FILE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(echo "${{ github.ref }}" | grep -oE "[0-9]+")
COMMENTS_URL="https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
COMMENTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" $COMMENTS_URL)
echo "$COMMENTS" > comments.json
- name: Check if comment already exists
if: env.FIRST_JS_FILE
run: |
COMMENT_EXISTS=$(cat comments.json | grep -c "/gallery/beta/${{ env.FIRST_JS_FILE }}")
if [ $COMMENT_EXISTS -ne 0 ]; then
echo "Comment already exists. Skipping."
exit 0
- name: Construct Preview URL and Post Comment
if: env.FIRST_JS_FILE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_NAME: "sprig"
BRANCH_NAME: "${{ github.head_ref }}"
FORK_AUTHOR: "${{ github.event.pull_request.head.user.login }}"
DOMAIN: "hackclub.dev"
JS_FILE: ${{ env.FIRST_JS_FILE }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: |
PR_NUMBER=$(echo "${{ github.ref }}" | grep -oE "[0-9]+")
if [ "${IS_FORK}" = "true" ]; then
PREVIEW_URL="https://${PROJECT_NAME}-git-fork-${FORK_AUTHOR}-${BRANCH_NAME}.${DOMAIN}"
else
PREVIEW_URL="https://${PROJECT_NAME}-git-${BRANCH_NAME}.${DOMAIN}"
fi
COMMENT_BODY="Your Game Preview is Available at [${PREVIEW_URL}/gallery/beta/${JS_FILE}](${PREVIEW_URL}/gallery/beta/${JS_FILE})"
curl -s -H "Authorization: token $GITHUB_TOKEN" \
-X POST \
-d "{\"body\": \"$COMMENT_BODY\"}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
2 changes: 1 addition & 1 deletion games/15_puzzle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
@title: 15 puzzle
@author: maggie
@tags: []
@tags: ["puzzle"]
@addedOn: 2022-07-18
INSTRUCTIONS:
Expand Down
2 changes: 1 addition & 1 deletion games/2048.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
@title: 2048
@author: linkai101
@tags: ['retro']
@tags: ["puzzle" , "endless"]
@addedOn: 2022-09-16
*/

Expand Down
Loading

0 comments on commit 92f9537

Please sign in to comment.