-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (74 loc) · 2.17 KB
/
crawl.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
# )
# })