Skip to content

Commit fb0b9e8

Browse files
committed
Create workflow for algolia
1 parent 9056792 commit fb0b9e8

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/algolia.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Algolia
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
jobs:
7+
# crawl:
8+
# runs-on: ubuntu-latest
9+
# steps:
10+
# - name: Get Code
11+
# uses: actions/checkout@v3
12+
# - name: Crawl Website
13+
# uses: darrenjennings/algolia-docsearch-action@master
14+
# with:
15+
# algolia_application_id: ${{ secrets.APPLICATION_ID }}
16+
# algolia_api_key: ${{ secrets.API_KEY }}
17+
# file: "./src/vuepress/config/algolia.json"
18+
19+
config:
20+
# runs-on: ubuntu-latest
21+
runs-on: macos-latest
22+
outputs:
23+
CONFIG: ${{ steps.load.outputs.config }}
24+
steps:
25+
- name: Get Code
26+
uses: actions/checkout@v3
27+
- name: Prepare config file
28+
run: echo "$(cat ./src/vuepress/config/algolia.json | jq -r tostring)" > config.json
29+
- name: Set output variable
30+
id: load
31+
run: echo "config=$(cat config.json)" >> $GITHUB_OUTPUT
32+
crawl:
33+
# runs-on: ubuntu-latest
34+
runs-on: macos-latest
35+
# container: algolia/docsearch-scraper
36+
needs: config
37+
env:
38+
CONFIG: ${{ needs.config.outputs.CONFIG }}
39+
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
40+
API_KEY: ${{ secrets.API_KEY }}
41+
steps:
42+
# - run: |
43+
# git clone https://github.com/algolia/docsearch-scraper.git
44+
# cd docsearch-scraper
45+
# python -m pip install pipenv
46+
# pipenv install
47+
# echo "${CONFIG}" > search.json
48+
# echo "APPLICATION_ID=${APPLICATION_ID}\nAPI_KEY=${API_KEY}\n" > .env
49+
# pipenv run python docsearch run search.json
50+
- run: git clone https://github.com/algolia/docsearch-scraper.git
51+
- run: |
52+
which python
53+
which python3
54+
brew install pipenv
55+
- run: which pipenv
56+
- run: |
57+
cd docsearch-scraper
58+
pipenv --python=$(which python3) install
59+
- run: echo "${CONFIG}" > search.json
60+
- run: echo "APPLICATION_ID=${APPLICATION_ID}\nAPI_KEY=${API_KEY}\n" > .env
61+
- run: pipenv --python=$(which python3) run python3 docsearch run search.json
62+
63+
# - run: |
64+
# sudo apt install python2
65+
# python2 --version
66+
# git clone https://github.com/algolia/docsearch-scraper.git
67+
# cd docsearch-scraper
68+
# sudo apt install python-pip
69+
# python2 -m pip install -U pipenv
70+
# pipenv install
71+
# echo "${CONFIG}" > search.json
72+
# echo "APPLICATION_ID=${APPLICATION_ID}\nAPI_KEY=${API_KEY}\n" > .env
73+
# pipenv run python2 docsearch run search.json
74+
75+
# python2 -m ensurepip --upgrade
76+
# - run: cd /root && pipenv install && run python -m pip install requests requests_iap scrapy algoliasearch selenium && pipenv run python -m src.index
77+
# - run: ping -c 4 www.google.com
78+
# - run: docker run --rm --network host -e "CONFIG=$CONFIG" -e "APPLICATION_ID=${{ secrets.APPLICATION_ID }}" -e "API_KEY=${{ secrets.API_KEY }}" algolia/docsearch-scraper
79+
# - run: echo "config ${CONFIG}"
80+
# - run: echo "appId ${APPLICATION_ID}"
81+
# - run: ls
82+
# - run: pwd
83+
# - run: ls /root
84+
# - run: ls /root/src
85+
# - run: cd /root && pipenv install && pipenv run python -m src.index
86+
# runs-on: ubuntu-latest
87+
# env:
88+
# APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
89+
# API_KEY: ${{ secrets.API_KEY }}
90+
# # container:
91+
# # algolia/docsearch-scraper
92+
# steps:
93+
# - name: Get Code
94+
# uses: actions/checkout@v3
95+
# - name: Prepare config file
96+
# run: echo "$(cat ./src/vuepress/config/algolia.json | jq -r tostring)" > config.json
97+
# - name: Set environment variable
98+
# run: echo "CONFIG=$(cat config.json)" >> $GITHUB_ENV
99+
# # run: echo "::set-env name=CONFIG::$(cat config.json)"
100+
# # - name: Run in Docker
101+
# # run:
102+
# # - name: Crawl website and update index
103+
# # run: docker run -e "CONFIG=$(cat ./src/vuepress/config/algolia.json | jq -r tostring)" algolia/docsearch-scraper
104+
# - run: echo $CONFIG
105+
# - name: Crawl website and update index
106+
# run: docker run --env-file <(env | grep -E "(CONFIG|APPLICATION\_ID|API\_KEY)") algolia/docsearch-scraper

0 commit comments

Comments
 (0)