[New Project Title]: elxpo generate #54
This file contains 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
name: Process Issue | |
on: | |
issues: | |
types: [closed] | |
jobs: | |
process-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Stash local changes | |
run: | | |
git stash | |
- name: Append issue body to projects.json | |
run: | | |
BODY=$(echo "${{ github.event.issue.body }}" | jq -sR .) | |
JSON_OBJECT="{\"content\": $BODY}" | |
# Check if projects.json exists | |
if [[ -f projects.json ]]; then | |
# If projects.json exists and isn't empty, append the new object | |
if [[ $(jq '. | length' projects.json) -gt 0 ]]; then | |
jq ". += [$JSON_OBJECT]" projects.json > projects.json.tmp && mv projects.json.tmp projects.json | |
else | |
echo "[$JSON_OBJECT]" > projects.json | |
fi | |
else | |
# If projects.json doesn't exist, create it with the new content | |
echo "[$JSON_OBJECT]" > projects.json | |
fi | |
- name: Pull latest changes from remote | |
run: | | |
git pull origin main | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'GitHub Actions Bot' | |
git config --global user.email 'actions@github.com' | |
git add projects.json | |
git commit -m "Update projects.json with issue body" | |
git push origin main | |
- name: Apply stashed changes (if any) | |
run: | | |
git stash pop || echo "No stashed changes" |