Skip to content

[addQR] Add New QR Code #1

[addQR] Add New QR Code

[addQR] Add New QR Code #1

Workflow file for this run

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
run: |
node actions/extractFields.js input.data
env:
INPUT_FILE: "input.data"
- 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: 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 user.name "GitHub Actions"
git config user.email "[email protected]"
git add app/data/institutions.ts
git commit -m "Add new institution from issue #${{ 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 'Merge ${{ steps.create_branch.outputs.branch }} into main' --body "resolve \#${{ github.event.issue.number }}
${{ github.event.issue.body }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}