Skip to content

[RECIPE]: Halloumi og bulgursalat #275

[RECIPE]: Halloumi og bulgursalat

[RECIPE]: Halloumi og bulgursalat #275

Workflow file for this run

name: Convert issue to PR
on:
issues:
types: [opened, edited, labeled]
jobs:
long-format-issue-to-pr-nb:
if: contains(github.event.issue.labels.*.name, 'nb') && contains(github.event.issue.labels.*.name, 'recipe') && contains(github.event.issue.labels.*.name, 'long-format')
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Parse issue
id: parse
uses: onmax/issue-form-parser@v1.5
with:
issue_number: ${{ github.event.issue.number }}
- name: Set up environment variables
run: |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "ISSUEUSER=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.name')" >> $GITHUB_ENV
echo "ISSUEUSER_ID=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.id')" >> $GITHUB_ENV
if [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" == "" ]]; then echo "CREATOR=$ISSUEUSER" >> $GITHUB_ENV; else echo "CREATOR=${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" >> $GITHUB_ENV; fi
if [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" == "" ]]; then echo "CREATORTITLE=Person" >> $GITHUB_ENV; elif [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsmakertittel }}" == "" ]]; then echo "CREATORTITLE=Person" >> $GITHUB_ENV; else echo "CREATORTITLE=${{ fromJson(steps.parse.outputs.payload).Opphavsmakertittel }}" >> $GITHUB_ENV; fi
if [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" == "" ]]; then echo "CREATORURL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV; else echo "CREATORURL=${{ fromJson(steps.parse.outputs.payload).Lenke }}" >> $GITHUB_ENV; fi
echo "TMPDIR=/tmp/src/${{ fromJson(steps.parse.outputs.payload).Kategori }}" >> $GITHUB_ENV
echo "TMPFILE=/tmp/src/${{ fromJson(steps.parse.outputs.payload).Kategori }}/${{ fromJson(steps.parse.outputs.payload).Filnavn }}.md" >> $GITHUB_ENV
echo "FILE_REL_TO_ROOT=src/${{ fromJson(steps.parse.outputs.payload).Kategori }}/${{ fromJson(steps.parse.outputs.payload).Filnavn }}.md" >> $GITHUB_ENV
echo "STATIC_DIR=src/static/${{ fromJson(steps.parse.outputs.payload).Filnavn }}/" >> $GITHUB_ENV
- name: Create recipe
run: |
mkdir -p "$TMPDIR"
touch "$TMPFILE"
cat << EOF > "$TMPFILE"
---
description: "${{ fromJson(steps.parse.outputs.payload).Tid[2] }} | ${{ fromJson(steps.parse.outputs.payload).Vanskelighetsgrad }}"
authors:
- name: "$ISSUEUSER (@${{ github.event.issue.user.login }})"
link: "${{ github.event.issue.user.html_url }}"
avatar: "${{ github.event.issue.user.avatar_url }}"
category:
- $ISSUEUSER
- ${{ fromJson(steps.parse.outputs.payload).Kategori }}
tag:
EOF
for tag in ${{ join(fromJson(steps.parse.outputs.payload).Emner, ' ') }}
do
echo " - $tag">>"$TMPFILE"
done
cat << EOF >> "$TMPFILE"
---
# ${{ fromJson(steps.parse.outputs.payload).Oppskriftsnavn }}
![](/static/${{ fromJson(steps.parse.outputs.payload).Filnavn }}/${{ fromJson(steps.parse.outputs.payload).Filnavn }}.webp)
EOF
if [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" != "" ]] && [[ "${{ fromJson(steps.parse.outputs.payload).Lenke }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
Denne oppskriften er originalt fra
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}"](${{ fromJson(steps.parse.outputs.payload).Lenke }})
!!!
EOF
elif [[ "${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
Denne oppskriften er originalt fra
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(steps.parse.outputs.payload).Opphavsnavn }}"]
!!!
EOF
fi
cat << EOF >> "$TMPFILE"
<!-- dprint-ignore-start -->
||| :timer_clock: Tid
${{ fromJson(steps.parse.outputs.payload).Tid[2] }}
||| :knife_fork_plate: Porsjoner
${{ fromJson(steps.parse.outputs.payload).Porsjoner }}
||| :cook: Vanskelighetsgrad
${{ fromJson(steps.parse.outputs.payload).Vanskelighetsgrad }}
|||
<!-- dprint-ignore-end -->
## Ingredienser
EOF
while IFS= read -r ingredient; do
echo "- $ingredient" >>"$TMPFILE"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Ingredienser }}")
cat << EOF >> "$TMPFILE"
## Steg
EOF
count=1
while IFS= read -r step; do
echo "$count. $step">>"$TMPFILE"
((count ++))
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Steg }}")
cat << EOF >> "$TMPFILE"
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"name": "${{ fromJson(steps.parse.outputs.payload).Oppskriftsnavn }}",
"image": "/static/${{ fromJson(steps.parse.outputs.payload).Filnavn }}/${{ fromJson(steps.parse.outputs.payload).Filnavn }}.webp",
"author": {
"@type": "$CREATORTITLE",
"name": "$CREATOR",
"url": "$CREATORURL"
},
"datePublished": "$DATE",
"description": "${{ fromJson(steps.parse.outputs.payload).Tid[2] }} | ${{ fromJson(steps.parse.outputs.payload).Vanskelighetsgrad }}",
"prepTime": "${{ fromJson(steps.parse.outputs.payload).Tid[0] }}",
"cookTime": "${{ fromJson(steps.parse.outputs.payload).Tid[1] }}",
"totalTime": "${{ fromJson(steps.parse.outputs.payload).Tid[2] }}",
"recipeYield": "${{ fromJson(steps.parse.outputs.payload).Porsjoner }}",
"recipeCategory": "${{ fromJson(steps.parse.outputs.payload).Kategori }}",
"recipeCuisine": "${{ fromJson(steps.parse.outputs.payload).Matkultur }}",
"keywords": "${{ join(fromJson(steps.parse.outputs.payload).Emner, ', ') }}",
"recipeIngredient": [
EOF
last_line=""
while IFS= read -r ingredient; do
if [[ "$last_line" != "" ]]; then
echo " \"$last_line\"," >>"$TMPFILE"
fi
last_line="$ingredient"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Ingredienser }}")
echo " \"$last_line\"" >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
],
"recipeInstructions": [
EOF
last_line=""
while IFS= read -r step; do
if [[ "$last_line" != "" ]]; then
printf ' {\n "@type": "HowToStep",\n "text": "%s"\n },\n' "$last_line" >>"$TMPFILE"
fi
last_line="$step"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Steg }}")
printf ' {\n "@type": "HowToStep",\n "text": "%s"\n }\n' "$last_line" >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
]
}
</script>
EOF
cat "$TMPFILE"
mv "$TMPFILE" ./"$FILE_REL_TO_ROOT"
mkdir -p ./"$STATIC_DIR"
touch ./"$STATIC_DIR"/image.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "${{ fromJson(steps.parse.outputs.payload).Filnavn }}"
add-paths: |
${{ env.FILE_REL_TO_ROOT }}
delete-branch: true
author: ${{ github.event.issue.user.login }} <${{ env.ISSUEUSER_ID }}+${{ github.event.issue.user.login }}@users.noreply.github.com>
reviewers: ${{ github.repository_owner }}
assignees: ${{ github.repository_owner }}
title: "feat(recipe): ${{ fromJson(steps.parse.outputs.payload).Oppskriftsnavn }}"
body: |
:robot: Jeg lagde akkurat en PR for å legge til ${{ fromJson(steps.parse.outputs.payload).Oppskriftsnavn }} på vegne av [@${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }}).
Resolves #${{ github.event.issue.number }}
labels: |
recipe
long-format-issue-to-pr-en:
if: contains(github.event.issue.labels.*.name, 'en') && contains(github.event.issue.labels.*.name, 'recipe') && contains(github.event.issue.labels.*.name, 'long-format')
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Parse issue
id: parse
uses: onmax/issue-form-parser@v1.5
with:
issue_number: ${{ github.event.issue.number }}
- name: Set up environment variables
run: |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "ISSUEUSER=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.name')" >> $GITHUB_ENV
echo "ISSUEUSER_ID=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.id')" >> $GITHUB_ENV
if [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" == "" ]]; then echo "CREATOR=$ISSUEUSER" >> $GITHUB_ENV; else echo "CREATOR=${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" >> $GITHUB_ENV; fi
if [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" == "" ]]; then echo "CREATORTITLE=Person" >> $GITHUB_ENV; elif [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-type }}" == "" ]]; then echo "CREATORTITLE=Person" >> $GITHUB_ENV; else echo "CREATORTITLE=${{ fromJson(steps.parse.outputs.payload).Contributor-type }}" >> $GITHUB_ENV; fi
if [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" == "" ]]; then echo "CREATORURL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV; else echo "CREATORURL=${{ fromJson(steps.parse.outputs.payload).URL }}" >> $GITHUB_ENV; fi
echo "TMPDIR=/tmp/src/${{ fromJson(steps.parse.outputs.payload).Category }}" >> $GITHUB_ENV
echo "TMPFILE=/tmp/src/${{ fromJson(steps.parse.outputs.payload).Category }}/${{ fromJson(steps.parse.outputs.payload).Filename }}.md" >> $GITHUB_ENV
echo "FILE_REL_TO_ROOT=src/${{ fromJson(steps.parse.outputs.payload).Category }}/${{ fromJson(steps.parse.outputs.payload).Filename }}.md" >> $GITHUB_ENV
echo "STATIC_DIR=src/static/${{ fromJson(steps.parse.outputs.payload).Filnavn }}/" >> $GITHUB_ENV
- name: Create recipe
run: |
mkdir -p "$TMPDIR"
touch "$TMPFILE"
cat << EOF > "$TMPFILE"
---
description: "${{ fromJson(steps.parse.outputs.payload).Time[2] }} | ${{ fromJson(steps.parse.outputs.payload).Difficulty }}"
authors:
- name: "$ISSUEUSER (@${{ github.event.issue.user.login }})"
link: "${{ github.event.issue.user.html_url }}"
avatar: "${{ github.event.issue.user.avatar_url }}"
category:
- $ISSUEUSER
- ${{ fromJson(steps.parse.outputs.payload).Category }}
tag:
EOF
for tag in ${{ join(fromJson(steps.parse.outputs.payload).Tags, ' ') }}
do
echo " - $tag">>"$TMPFILE"
done
cat << EOF >> "$TMPFILE"
---
# ${{ fromJson(steps.parse.outputs.payload).Recipe-name }}
![](/static/${{ fromJson(steps.parse.outputs.payload).Filename }}/${{ fromJson(steps.parse.outputs.payload).Filename }}.webp)
EOF
if [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" != "" ]] && [[ "${{ fromJson(steps.parse.outputs.payload).URL }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
This recipe is originally from
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(steps.parse.outputs.payload).Contributor-name }}"](${{ fromJson(steps.parse.outputs.payload).URL }})
!!!
EOF
elif [[ "${{ fromJson(steps.parse.outputs.payload).Contributor-name }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
This recipe is originally from
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(steps.parse.outputs.payload).Contributor-name }}"]
!!!
EOF
fi
cat << EOF >> "$TMPFILE"
<!-- dprint-ignore-start -->
||| :timer_clock: Time
${{ fromJson(steps.parse.outputs.payload).Time[2] }}
||| :knife_fork_plate: Portions
${{ fromJson(steps.parse.outputs.payload).Portions }}
||| :cook: Difficulty
${{ fromJson(steps.parse.outputs.payload).Difficulty }}
|||
<!-- dprint-ignore-end -->
## Ingredients
EOF
while IFS= read -r ingredient; do
echo "- $ingredient" >>"$TMPFILE"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Ingredients }}")
cat << EOF >> "$TMPFILE"
## Steps
EOF
count=1
while IFS= read -r step; do
echo "$count. $step">>"$TMPFILE"
((count ++))
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Steps }}")
cat << EOF >> "$TMPFILE"
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"name": "${{ fromJson(steps.parse.outputs.payload).Recipe-name }}",
"image": "/static/${{ fromJson(steps.parse.outputs.payload).Filename }}/${{ fromJson(steps.parse.outputs.payload).Filename }}.webp",
"author": {
"@type": "$CREATORTITLE",
"name": "$CREATOR",
"url": "$CREATORURL"
},
"datePublished": "$DATE",
"description": "${{ fromJson(steps.parse.outputs.payload).Time[2] }} | ${{ fromJson(steps.parse.outputs.payload).Difficulty }}",
"prepTime": "${{ fromJson(steps.parse.outputs.payload).Time[0] }}",
"cookTime": "${{ fromJson(steps.parse.outputs.payload).Time[1] }}",
"totalTime": "${{ fromJson(steps.parse.outputs.payload).Time[2] }}",
"recipeYield": "${{ fromJson(steps.parse.outputs.payload).Portions }}",
"recipeCategory": "${{ fromJson(steps.parse.outputs.payload).Category }}",
"recipeCuisine": "${{ fromJson(steps.parse.outputs.payload).Cuisine }}",
"keywords": "${{ join(fromJson(steps.parse.outputs.payload).Tags, ', ') }}",
"recipeIngredient": [
EOF
last_line=""
while IFS= read -r ingredient; do
if [[ "$last_line" != "" ]]; then
echo " \"$last_line\"," >>"$TMPFILE"
fi
last_line="$ingredient"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Ingredients }}")
echo " \"$last_line\"" >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
],
"recipeInstructions": [
EOF
last_line=""
while IFS= read -r step; do
if [[ "$last_line" != "" ]]; then
printf ' {\n "@type": "HowToStep",\n "text": "%s"\n },\n' "$last_line" >>"$TMPFILE"
fi
last_line="$step"
done < <(echo "${{ fromJson(steps.parse.outputs.payload).Steps }}")
printf ' {\n "@type": "HowToStep",\n "text": "%s"\n }\n' "$last_line" >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
]
}
</script>
EOF
cat "$TMPFILE"
mv "$TMPFILE" ./"$FILE_REL_TO_ROOT"
mkdir -p ./"$STATIC_DIR"
touch ./"$STATIC_DIR"/image.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "${{ fromJson(steps.parse.outputs.payload).Filename }}"
add-paths: |
${{ env.FILE_REL_TO_ROOT }}
delete-branch: true
author: ${{ github.event.issue.user.login }} <${{ env.ISSUEUSER_ID }}+${{ github.event.issue.user.login }}@users.noreply.github.com>
reviewers: ${{ github.repository_owner }}
assignees: ${{ github.repository_owner }}
title: "feat(recipe): ${{ fromJson(steps.parse.outputs.payload).Recipe-name }}"
body: |
:robot: I just made a PR to add ${{ fromJson(steps.parse.outputs.payload).Recipe-name }} on behalf of [@${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }}).
Resolves #${{ github.event.issue.number }}
labels: |
recipe
url-issue-to-pr-nb:
if: contains(github.event.issue.labels.*.name, 'nb') && contains(github.event.issue.labels.*.name, 'recipe') && contains(github.event.issue.labels.*.name, 'recipe-scrapers')
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Parse issue
id: parse
uses: onmax/issue-form-parser@v1.5
with:
issue_number: ${{ github.event.issue.number }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install scripts with mise
id: scraper
run: |
curl https://mise.jdx.dev/install.sh | sh
echo "$HOME/.local/share/mise/bin">> $GITHUB_PATH
echo "$HOME/.local/share/mise/shims">> $GITHUB_PATH
eval "$(mise activate bash)"
mise settings set experimental true
mise run recipe-scrapers:install
echo "PARSED=$(mise run recipe-scrapers:run ${{ fromJson(steps.parse.outputs.payload).Lenke }} | jq -c)" >> $GITHUB_ENV
echo "TITLE=$(mise run recipe-scrapers:title-to-filepathname '${{ fromJson(steps.parse.outputs.payload).Tittel }}')" >> $GITHUB_ENV
echo "TITLEHUMAN=${{ fromJson(steps.parse.outputs.payload).Tittel }}" >> $GITHUB_ENV
- name: Set up environment variables
run: |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "ISSUEUSER=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.name')" >> $GITHUB_ENV
echo "ISSUEUSER_ID=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.id')" >> $GITHUB_ENV
if [[ "${{ fromJson(env.PARSED).author.name }}" == "" ]]; then echo "CREATOR=${{env.ISSUEUSER}}" >> $GITHUB_ENV; else echo "CREATOR=${{ fromJson(env.PARSED).author.name }}" >> $GITHUB_ENV; fi
echo "CREATORTITLE=Person" >> $GITHUB_ENV
if [[ "${{ fromJson(env.PARSED).author.name }}" == "" ]]; then echo "CREATORURL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV; else echo "CREATORURL=${{ fromJson(env.PARSED).author.url }}" >> $GITHUB_ENV; fi
CATEGORY=${{ fromJson(steps.parse.outputs.payload).Kategori }}
echo "CATEGORY=${{ fromJson(steps.parse.outputs.payload).Kategori }}" >> $GITHUB_ENV
echo "TMPDIR=/tmp/src/$CATEGORY" >> $GITHUB_ENV
echo "TMPFILE=/tmp/src/$CATEGORY/${{ env.TITLE }}.md" >> $GITHUB_ENV
echo "FILE_REL_TO_ROOT=src/$CATEGORY/${{ env.TITLE }}.md" >> $GITHUB_ENV
echo "STATIC_DIR=src/static/${{ env.TITLE }}/" >> $GITHUB_ENV
- name: Create recipe
run: |
mkdir -p "$TMPDIR"
touch "$TMPFILE"
cat << EOF > "$TMPFILE"
---
description: "${{ fromJson(env.PARSED).totalTime }} | ${{ fromJson(steps.parse.outputs.payload).Vanskelighetsgrad }}"
authors:
- name: "$ISSUEUSER (@${{ github.event.issue.user.login }})"
link: "${{ github.event.issue.user.html_url }}"
avatar: "${{ github.event.issue.user.avatar_url }}"
date: $DATE
category:
- $ISSUEUSER
- $CATEGORY
tag:
EOF
for tag in ${{ join(fromJson(steps.parse.outputs.payload).Emner, ' ') }}
do
echo " - $tag">>"$TMPFILE"
done
cat << EOF >> "$TMPFILE"
---
# ${{ env.TITLEHUMAN }}
![](/static/${{ env.TITLE }}/${{ env.TITLE }}.webp)
EOF
if [[ "${{ fromJson(env.PARSED).author.name }}" != "" ]] && [[ "${{ fromJson(steps.parse.outputs.payload).Lenke }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
Denne oppskriften er originalt fra
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(env.PARSED).author.name }}"](${{ fromJson(steps.parse.outputs.payload).Lenke }})
!!!
EOF
elif [[ "${{ fromJson(env.PARSED).author.name }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
Denne oppskriften er originalt fra
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(env.PARSED).author.name }}"]
!!!
EOF
fi
cat << EOF >> "$TMPFILE"
<!-- dprint-ignore-start -->
||| :timer_clock: Tid
${{ fromJson(env.PARSED).totalTime }}
||| :knife_fork_plate: Porsjoner
${{ fromJson(env.PARSED).recipeYield }}
||| :cook: Vanskelighetsgrad
${{ fromJson(steps.parse.outputs.payload).Vanskelighetsgrad }}
|||
<!-- dprint-ignore-end -->
## Ingredienser
EOF
while IFS= read -r ingredient; do
echo "- $ingredient" >>"$TMPFILE"
done < <(echo $PARSED | jq -r '.recipeIngredient[]')
cat << EOF >> "$TMPFILE"
## Steg
EOF
count=1
while IFS= read -r step; do
echo "$count. $step">>"$TMPFILE"
((count ++))
done < <(echo "$PARSED" | jq -r '.recipeInstructions[].text')
cat << EOF >> "$TMPFILE"
<script type="application/ld+json">
EOF
echo "$PARSED" | jq >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
</script>
EOF
cat "$TMPFILE"
mv "$TMPFILE" ./"$FILE_REL_TO_ROOT"
mkdir -p ./"$STATIC_DIR"
touch ./"$STATIC_DIR"/image.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "${{ env.TITLE }}"
add-paths: |
${{ env.FILE_REL_TO_ROOT }}
${{ env.STATIC_DIR }}
delete-branch: true
author: ${{ github.event.issue.user.login }} <${{ env.ISSUEUSER_ID }}+${{ github.event.issue.user.login }}@users.noreply.github.com>
reviewers: ${{ github.repository_owner }}
assignees: ${{ github.repository_owner }}
title: "feat(recipe): ${{ fromJson(env.PARSED).name }}"
body: |
:robot: Jeg lagde akkurat en PR for å legge til ${{ env.TITLEHUMAN }} på vegne av [@${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }}).
Resolves #${{ github.event.issue.number }}
labels: |
recipe
url-issue-to-pr-en:
if: contains(github.event.issue.labels.*.name, 'en') && contains(github.event.issue.labels.*.name, 'recipe') && contains(github.event.issue.labels.*.name, 'recipe-scrapers')
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Parse issue
id: parse
uses: onmax/issue-form-parser@v1.5
with:
issue_number: ${{ github.event.issue.number }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install scripts with mise
id: scraper
run: |
curl https://mise.jdx.dev/install.sh | sh
echo "$HOME/.local/share/mise/bin">> $GITHUB_PATH
echo "$HOME/.local/share/mise/shims">> $GITHUB_PATH
eval "$(mise activate bash)"
mise settings set experimental true
mise run recipe-scrapers:install
echo "PARSED=$(mise run recipe-scrapers:run ${{ fromJson(steps.parse.outputs.payload).URL }} | jq -c)" >> $GITHUB_ENV
echo "TITLE=$(mise run recipe-scrapers:title-to-filepathname '${{ fromJson(steps.parse.outputs.payload).Title }}')" >> $GITHUB_ENV
echo "TITLEHUMAN=${{ fromJson(steps.parse.outputs.payload).Title }}" >> $GITHUB_ENV
- name: Set up environment variables
run: |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "ISSUEUSER=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.name')" >> $GITHUB_ENV
echo "ISSUEUSER_ID=$(curl -s ${{ github.event.issue.user.url }} | jq -r '.id')" >> $GITHUB_ENV
if [[ "${{ fromJson(env.PARSED).author.name }}" == "" ]]; then echo "CREATOR=${{env.ISSUEUSER}}" >> $GITHUB_ENV; else echo "CREATOR=${{ fromJson(env.PARSED).author.name }}" >> $GITHUB_ENV; fi
echo "CREATORTITLE=Person" >> $GITHUB_ENV
if [[ "${{ fromJson(env.PARSED).author.name }}" == "" ]]; then echo "CREATORURL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV; else echo "CREATORURL=${{ fromJson(env.PARSED).author.url }}" >> $GITHUB_ENV; fi
CATEGORY=${{ fromJson(steps.parse.outputs.payload).Category }}
echo "CATEGORY=${{ fromJson(steps.parse.outputs.payload).Category }}" >> $GITHUB_ENV
echo "TMPDIR=/tmp/src/$CATEGORY" >> $GITHUB_ENV
echo "TMPFILE=/tmp/src/$CATEGORY/${{ env.TITLE }}.md" >> $GITHUB_ENV
echo "FILE_REL_TO_ROOT=src/$CATEGORY/${{ env.TITLE }}.md" >> $GITHUB_ENV
echo "STATIC_DIR=src/static/${{ env.TITLE }}/" >> $GITHUB_ENV
- name: Create recipe
run: |
mkdir -p "$TMPDIR"
touch "$TMPFILE"
cat << EOF > "$TMPFILE"
---
description: "${{ fromJson(env.PARSED).totalTime }} | ${{ fromJson(steps.parse.outputs.payload).Difficulty }}"
authors:
- name: "$ISSUEUSER (@${{ github.event.issue.user.login }})"
link: "${{ github.event.issue.user.html_url }}"
avatar: "${{ github.event.issue.user.avatar_url }}"
date: $DATE
category:
- $ISSUEUSER
- $CATEGORY
tag:
EOF
for tag in ${{ join(fromJson(steps.parse.outputs.payload).Tags, ' ') }}
do
echo " - $tag">>"$TMPFILE"
done
cat << EOF >> "$TMPFILE"
---
# ${{ env.TITLEHUMAN }}
![](/static/${{ env.TITLE }}/${{ env.TITLE }}.webp)
EOF
if [[ "${{ fromJson(env.PARSED).author.name }}" != "" ]] && [[ "${{ fromJson(steps.parse.outputs.payload).URL }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
The recipe is originally from
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(env.PARSED).author.name }}"](${{ fromJson(steps.parse.outputs.payload).URL }})
!!!
EOF
elif [[ "${{ fromJson(env.PARSED).author.name }}" != "" ]]; then
cat << EOF >> "$TMPFILE"
!!!info
The recipe is originally from
[!badge variant="dark" iconAlign="right" margin="0 0 0 4" icon=":cook:" size="l" target="blank" text="${{ fromJson(env.PARSED).author.name }}"]
!!!
EOF
fi
cat << EOF >> "$TMPFILE"
<!-- dprint-ignore-start -->
||| :timer_clock: Time
${{ fromJson(env.PARSED).totalTime }}
||| :knife_fork_plate: Portions
${{ fromJson(env.PARSED).recipeYield }}
||| :cook: Difficulty
${{ fromJson(steps.parse.outputs.payload).Difficulty }}
|||
<!-- dprint-ignore-end -->
## Ingredients
EOF
while IFS= read -r ingredient; do
echo "- $ingredient" >>"$TMPFILE"
done < <(echo $PARSED | jq -r '.recipeIngredient[]')
cat << EOF >> "$TMPFILE"
## Steps
EOF
count=1
while IFS= read -r step; do
echo "$count. $step">>"$TMPFILE"
((count ++))
done < <(echo "$PARSED" | jq -r '.recipeInstructions[].text')
cat << EOF >> "$TMPFILE"
<script type="application/ld+json">
EOF
echo "$PARSED" | jq >>"$TMPFILE"
cat << EOF >> "$TMPFILE"
</script>
EOF
cat "$TMPFILE"
mv "$TMPFILE" ./"$FILE_REL_TO_ROOT"
mkdir -p ./"$STATIC_DIR"
touch ./"$STATIC_DIR"/image.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "${{ env.TITLE }}"
add-paths: |
${{ env.FILE_REL_TO_ROOT }}
${{ env.STATIC_DIR }}
delete-branch: true
author: ${{ github.event.issue.user.login }} <${{ env.ISSUEUSER_ID }}+${{ github.event.issue.user.login }}@users.noreply.github.com>
reviewers: ${{ github.repository_owner }}
assignees: ${{ github.repository_owner }}
title: "feat(recipe): ${{ fromJson(env.PARSED).name }}"
body: |
:robot: I just made a PR to add ${{ env.TITLEHUMAN }} on behalf of [@${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }}).
Resolves #${{ github.event.issue.number }}
labels: |
recipe