1+ # SPDX-FileCopyrightText: 2021 Pen-Yuan Hsing
2+ # SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+ # References:
5+ # https://news.ycombinator.com/item?id=24732943
6+ # https://github.com/simonw/ca-fires-history/blob/main/.github/workflows/scrape.yml
7+ # https://github.com/openZH/covid_19/blob/master/.github/workflows/run_scrapers.yml
8+
9+ name : Run miner
10+
11+ # Controls when the action will run.
12+ on :
13+ # Triggers on schedule
14+ schedule :
15+ - cron : 30 2 * * 3 # 02:30 UTC every Wednesday: https://crontab.guru/#30_2_*_*_3
16+ # Allows you to run this workflow manually from the Actions tab
17+ workflow_dispatch :
18+
19+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
20+ jobs :
21+ # This workflow contains a single job called "mine"
22+ mine :
23+ # The type of runner that the job will run on
24+ runs-on : ubuntu-latest
25+ continue-on-error : false # Abort on errors
26+ timeout-minutes : 90
27+
28+ # Steps represent a sequence of tasks that will be executed as part of the job
29+ steps :
30+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+ - name : Check-out repository
32+ uses : actions/checkout@v2
33+
34+ - name : Set up Python 3.8
35+ uses : actions/setup-python@v2
36+ with :
37+ python-version : ' 3.8'
38+ architecture : ' x64'
39+
40+ - name : Cache pip # https://docs.github.com/en/actions/guides/building-and-testing-python
41+ uses : actions/cache@v2
42+ with :
43+ # Ubuntu-specific path
44+ path : ~/.cache/pip
45+ # See if there is a cache hit for the corresponding requirements file
46+ key : ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
47+ restore-keys : |
48+ ${{ runner.os }}-pip-
49+ ${{ runner.os }}-
50+
51+ - name : Install dependencies
52+ run : |
53+ python -m pip install --upgrade pip setuptools wheel
54+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
55+
56+ - name : Run `osmine`
57+ env :
58+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59+ run : python osmine -r=./input/OSH-repos.csv
60+
61+ - name : Check if there are file change(s) # Presumably `mined_data.zip`
62+ id : changes
63+ uses :
UnicornGlobal/[email protected] 64+
65+ - name : Set commit message # If there are file change(s)
66+ if : steps.changes.outputs.changed == 1
67+ run : |
68+ echo "commit_msg=`osmine` Action ${timestamp}" >> $GITHUB_ENV
69+
70+ - name : Commit new file
71+ if : steps.changes.outputs.changed == 1
72+ uses :
github-actions-x/[email protected] 73+ with :
74+ github-token : ${{ secrets.GITHUB_TOKEN }}
75+ push-branch : ' main'
76+ commit-message : ${{ env.commit_msg }}
77+ name : GitHub Actions
78+ 79+
80+ - name : Message if no changes
81+ if : steps.changes.outputs.changed == 0
82+ run : echo "No changes during this run"
0 commit comments