-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathentrypoint.sh
executable file
·74 lines (53 loc) · 1.48 KB
/
entrypoint.sh
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
#!/bin/sh
export WORKSPACE_REPOSITORY="$INPUT_REPOSITORY"
export CRAWLER_REPOSITORY="$INPUT_CRAWLER"
export OUTPUT_REPOSITORY="$INPUT_OUTPUT"
unset INPUT_REPOSITORY
# Clone crawler
echo "Cloning crawler..."
mkdir /crawler
export INPUT_REF="$INPUT_CRAWLERREF"
export GITHUB_WORKSPACE="/crawler"
export GITHUB_REPOSITORY="$CRAWLER_REPOSITORY"
node /checkout.js
# Install crawler dependencies
echo "Installing crawler dependencies..."
cd /crawler
npm install
# Clone workspace
echo "Cloning workspace..."
mkdir /workspace
export INPUT_REF="$INPUT_CURRENT_BRANCH"
export GITHUB_WORKSPACE="/workspace"
export GITHUB_REPOSITORY="$WORKSPACE_REPOSITORY"
node /checkout.js
# Inject .env from workspace
echo "Injecting .env from workspace..."
touch /workspace/.env
cp /workspace/.env /crawler/.env
# Clone output
echo "Cloning output..."
mkdir /output
export INPUT_REF="$INPUT_BRANCH"
export GITHUB_WORKSPACE="/output"
export GITHUB_REPOSITORY="$OUTPUT_REPOSITORY"
node /checkout.js
# Run crawler
echo "Running crawler..."
export OUTPUT="/output/$INPUT_OUTPUTFOLDER"
export EMAIL="$INPUT_EMAIL"
export PASSWORD="$INPUT_PASSWORD"
node /crawler/index.js
# Commit changes
echo "Commiting changes..."
cd /output
git add .
git commit -m "$INPUT_COMMITMESSAGE"
# Push changes
echo "Pushing changes..."
force_option=""
if $INPUT_FORCE; then
force_option="--force"
fi
remote="https://$INPUT_ACTOR:$INPUT_TOKEN@github.com/$OUTPUT_REPOSITORY.git"
git push $remote "HEAD:$INPUT_BRANCH" $force_option && exit 0