-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (60 loc) · 1.95 KB
/
crawl-kdb.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
name: Crawl KdB
permissions:
contents: write
on:
schedule:
- cron: "0 15 * * *"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
crawl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Delete dist/
run: rm -r dist/
# - name: Setup Rust
# run: |
# rustup set profile minimal
# rustup install stable
# rustup override set stable
# rustup component add clippy
- name: Cache Rust project
id: cache-rust-project
uses: actions/cache@v4
with:
path: ./target/release/kdb-crawler
key: ${{ runner.os }}-binary-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
- uses: dtolnay/rust-toolchain@stable
if: steps.cache-rust-project.outputs.cache-hit != 'true'
- name: Build
run: cargo build --release
if: steps.cache-rust-project.outputs.cache-hit != 'true'
- name: Run binary
run: ./target/release/kdb-crawler
# - name: Upload release asset
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# files: ./dist/kdb.json
- name: Check for empty commit
id: check_empty_commit
run: |
if [ -z "$(git status --porcelain --ignored | grep 'M dist/')" ]; then
echo "KdB に差分が存在しないため、以降のタスクをスキップします。"
echo "skip_commit=true" >> $GITHUB_ENV
else
echo "skip_commit=false" >> $GITHUB_ENV
fi
- name: Commit files
if: env.skip_commit == 'false'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -f ./dist/
DATE=$(date -u +"%Y-%m-%d")
git commit -m "Update KdB to $DATE"
git push