Crawl #47
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: Crawl | |
on: | |
workflow_dispatch: | |
inputs: | |
session_id: | |
default: NONE | |
description: Php Session ID use to bypass login | |
required: true | |
type: string | |
hook: | |
default: https://www.google.com | |
description: Hook to trigger after done with scraping. e.g. https://vercel.com/docs/deployments/deploy-hooks | |
required: true | |
type: string | |
jobs: | |
crawl: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Git repository | |
uses: actions/checkout@v4 | |
- name: Create .env file | |
run: | | |
echo "NODE_ENV=${{ secrets.NODE_ENV }}" > .env | |
echo "OPEN_DB_KEY=${{ secrets.OPEN_DB_KEY }}" >> .env | |
echo "OPEN_DB_IV=${{ secrets.OPEN_DB_IV }}" >> .env | |
echo "PHPSESSID=${{ inputs.session_id }}" >> .env | |
echo "VERCEL_DEPLOYMENT_HOOK=${{ inputs.hook }}" >> .env | |
- name: Install Packages | |
run: yarn | |
- name: Burn 🔥 | |
run: yarn dev | |
- name: Push to Github | |
run: | | |
git add ./db | |
git config --global user.name "Zain-ul-din" | |
git config --global user.email "[email protected]" | |
git commit -m "🤖 Github Action: updated encrypted DB" | |
git push origin master | |
- name: Trigger Hook 🪝 | |
run: node ./scripts/vercel-deploy.js | |
## | |
## | |
## Appendix: | |
## https://stackoverflow.com/questions/72851548/permission-denied-to-github-actionsbot | |
## | |
##A | |
## | |
## Trigger Action using API call | |
## https://github.com/jbranchaud/til/blob/master/github-actions/trigger-a-workflow-via-an-api-call.md | |
## | |
## | |
## USAGE: | |
## | |
# const endPoint = `https://api.github.com/repos/Zain-ul-din/lgu-crawler/actions/workflows/89946576/dispatches` | |
# const TOKEN = `YOUR_TOKEN` | |
# fetch(endPoint, { | |
# method: 'POST', | |
# headers: { | |
# "Accept": "application/vnd.github+json", | |
# "Authorization": `Bearer ${TOKEN}`, | |
# "X-GitHub-Api-Version": "2022-11-28", | |
# }, | |
# body: JSON.stringify({ | |
# ref: "master", | |
# inputs: { session_id: 'actual_session_id' } | |
# }) | |
# }).then(res => { | |
# return res.text() | |
# }).then(res => { | |
# console.log(res) | |
# }).catch(err=> { | |
# console.log('error ', err | |
# ) | |
# }) |