Skip to content
name: Create File on Issue Close
on:
issues:
types:
- closed
jobs:
process_issue:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Install dependencies
run: npm install
- name: Check if the issue is closed
run: |
SLUG=$(echo "${{ github.event.issue.title }}" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
FILE_PATH="src/app/users/${SLUG}.js"
# Check if the file already exists for the issue
if [ ! -f "${FILE_PATH}" ]; then
# Use Node.js to handle base64 decoding and file appending
node -e "const fs = require('fs'); const content = Buffer.from('${{ github.event.issue.body }}', 'base64').toString('utf-8'); fs.appendFileSync('${FILE_PATH}', content); console.log('File ${FILE_PATH} created successfully.');"
# Add and commit the new content
git add "${FILE_PATH}"
git commit -m "Add content for issue: $SLUG"
git push
else
echo "File ${FILE_PATH} already exists. Skipping."
fi