setup datatable and create institution page #49
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: Add New Institution | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
add-qrcode: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check for [addQR] Keyword | |
id: check_keyword | |
run: | | |
ISSUE_TITLE="${{ github.event.issue.title }}" | |
ISSUE_BODY="${{ github.event.issue.body }}" | |
if [[ "$ISSUE_TITLE" != *"[addQR]"* && "$ISSUE_BODY" != *"[addQR]"* ]]; then | |
echo "No [addQR] keyword found. Exiting workflow." | |
exit 78 | |
fi | |
echo "Keyword [addQR] found. Proceeding with workflow." | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Install Dependencies | |
run: | | |
npm install axios --legacy-peer-deps | |
- name: Create Input File | |
run: | | |
echo "${{ github.event.issue.body }}" > input.data | |
- name: Run Extract Fields Script | |
id: extract | |
run: | | |
echo "${{ github.event.issue.number }}" | |
node actions/extractFields.js input.data | |
env: | |
INPUT_FILE: "input.data" | |
ISSUE_ID: "${{ github.event.issue.number }}" | |
- name: Append Data to institutions.ts | |
run: | | |
node actions/append_institution.js | |
env: | |
TYPE_OF_INSTITUTE: "${{ steps.extract.outputs.typeOfInstitute }}" | |
NAME_OF_MASJID: "${{ steps.extract.outputs.nameOfMasjid }}" | |
CITY: "${{ steps.extract.outputs.nameOfTheCity }}" | |
STATE: "${{ steps.extract.outputs.state }}" | |
IMAGE_URL: "${{ steps.extract.outputs.qrCodeImage }}" | |
- name: Show Git Diff | |
run: | | |
echo "Displaying git diff for changes in institutions.ts" | |
git diff app/data/institutions.ts | |
rm -rf extractedFields.json input.data | |
git checkout package.json | |
- name: Get Issue Author Details | |
id: author | |
run: | | |
AUTHOR_NAME=$(gh api /users/${{ github.event.issue.user.login }} --jq .name) | |
AUTHOR_EMAIL=$(gh api /users/${{ github.event.issue.user.login }} --jq .email) | |
AUTHOR_LOGIN="${{ github.event.issue.user.login }}" | |
if [ "$AUTHOR_NAME" = "" ]; then | |
AUTHOR_NAME="${AUTHOR_LOGIN}" | |
fi | |
if [ "$AUTHOR_EMAIL" = "" ]; then | |
AUTHOR_EMAIL="${AUTHOR_LOGIN}@users.noreply.github.com" | |
fi | |
echo "name=$AUTHOR_NAME" >> $GITHUB_OUTPUT | |
echo "email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create, Commit, and Push New Branch | |
id: create_branch | |
run: | | |
BRANCH_NAME="add-institution-${{ github.event.issue.number }}" | |
echo "Creating branch: $BRANCH_NAME" | |
git checkout -b "$BRANCH_NAME" | |
git config --global user.name "${{ steps.author.outputs.name }}" | |
git config --global user.email "${{ steps.author.outputs.email }}" | |
git add app/data/institutions.ts | |
git commit -m ":memo: add new institution from #${{ github.event.issue.number }}" | |
echo "Pushing branch $BRANCH_NAME to origin..." | |
git push origin "$BRANCH_NAME" --verbose | |
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
run: | | |
gh pr create \ | |
-B main \ | |
-H ${{ steps.create_branch.outputs.branch }} \ | |
--title ':memo: add new institution from #${{ github.event.issue.number }}' \ | |
--body "closes \#${{ github.event.issue.number }} | |
${{ github.event.issue.body }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |