test32 #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: 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 Git | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Kartikeya Saini" | |
- 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 | |
ISSUE_BODY="${{ github.event.issue.body }}" | |
# Create the file and append data using cat | |
cat <<EOL > "${FILE_PATH}" | |
const data = { | |
issueBody: \` | |
$ISSUE_BODY | |
\` | |
}; | |
export default data; | |
EOL | |
# Add and commit the new file | |
git add "${FILE_PATH}" | |
git commit -m "Add file for issue: $SLUG" | |
git push | |
else | |
echo "File ${FILE_PATH} already exists. Skipping." | |
fi |