-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Update Recipe Cookbook Submission Flow #3064
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ee4fa80
update recipe issue
EbonyLouis 47623ee
update context variable
EbonyLouis ba91d94
fix run block
EbonyLouis 698bf37
env variable
EbonyLouis 896bf16
pinned version
EbonyLouis 19882ed
clarity
angiejones 9e4fbe4
addressing PR comments
EbonyLouis f6c8a37
change from json to yaml
EbonyLouis 78b5082
pr comment
EbonyLouis f0a6218
remove category
EbonyLouis d226fa8
shell injection fix
EbonyLouis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Handle Recipe Submissions | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened] | ||
| labels: | ||
| - recipe submission | ||
|
|
||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| create-recipe-pr: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Parse recipe from issue | ||
| id: parse | ||
| run: | | ||
| ISSUE_BODY=$(jq -r .issue.body "$GITHUB_EVENT_PATH") | ||
|
|
||
| # Extract the JSON block from the issue body | ||
| RECIPE_JSON=$(echo "$ISSUE_BODY" | awk '/```/,/```/' | sed '1d;$d') | ||
|
|
||
| echo "$RECIPE_JSON" > recipe.json | ||
|
angiejones marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Extract title to use as a slug | ||
| TITLE=$(jq -r .title recipe.json | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-') | ||
| BRANCH_NAME="add-recipe-${TITLE}" | ||
|
|
||
| echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
| echo "recipe_json=${RECIPE_JSON}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Validate recipe fields | ||
|
EbonyLouis marked this conversation as resolved.
Outdated
|
||
| run: | | ||
| REQUIRED_FIELDS=(id title description instructions action category extensions activities author) | ||
| for field in "${REQUIRED_FIELDS[@]}"; do | ||
| VALUE=$(jq -r ".${field}" recipe.json) | ||
| if [[ "$VALUE" == "null" || "$VALUE" == "" ]]; then | ||
| echo "β Missing required field: $field" | ||
| exit 1 | ||
| fi | ||
| done | ||
| echo "β All required fields present." | ||
|
|
||
| - name: Generate recipeUrl and update JSON | ||
| run: | | ||
| BASE64_ENCODED=$(jq -c . recipe.json | base64 | tr -d '\n') | ||
| RECIPE_URL="goose://recipe?config=${BASE64_ENCODED}" | ||
| jq --arg url "$RECIPE_URL" '. + {recipeUrl: $url}' recipe.json > updated-recipe.json | ||
|
|
||
| - name: Create branch and add file | ||
| run: | | ||
| BRANCH_NAME=${{ steps.parse.outputs.branch_name }} | ||
| git checkout -b "$BRANCH_NAME" | ||
|
|
||
| DEST_DIR="documentation/src/pages/recipes/data/recipes" | ||
| mkdir -p "$DEST_DIR" | ||
|
|
||
| ID=$(jq -r .id updated-recipe.json) | ||
| cp updated-recipe.json "$DEST_DIR/${ID}.json" | ||
|
|
||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add "$DEST_DIR/${ID}.json" | ||
| git commit -m "Add recipe: ${ID}" | ||
| git push origin "$BRANCH_NAME" | ||
|
|
||
|
|
||
| - name: Create pull request | ||
| id: cpr | ||
| uses: peter-evans/create-pull-request@v5 | ||
|
|
||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: ${{ steps.parse.outputs.branch_name }} | ||
| title: "Add recipe: ${{ fromJson(steps.parse.outputs.recipe_json).title }}" | ||
| body: "This PR adds a new Goose recipe submitted via issue #${{ github.event.issue.number }}." | ||
| reviewers: | | ||
| EbonyLouis | ||
| angiejones | ||
| blackgirlbytes | ||
|
|
||
| - name: Comment and close issue | ||
| run: | | ||
| ISSUE_NUMBER=${{ github.event.issue.number }} | ||
| PR_URL=${{ steps.cpr.outputs.pull-request-url }} | ||
|
|
||
| gh issue comment "$ISSUE_NUMBER" --body "π Thanks for submitting your recipe! We've created a [PR]($PR_URL) to add it to the Cookbook." | ||
| gh issue close "$ISSUE_NUMBER" | ||
|
|
||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.