CD #790
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
concurrency: | |
# ensure that only a single job using the same concurrency group will run at a time. | |
# A concurrency group can be any string or expression. | |
group: mars | |
on: | |
push: | |
branches: [ master ] | |
schedule: | |
- cron: "0 7 * * *" | |
# allow manually trigger a build | |
workflow_dispatch: | |
jobs: | |
CD: | |
# https://github.com/actions/runner-images/tree/main/images/linux | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
# | |
# Number of commits to fetch. 0 indicates all history for all branches and tags. | |
# Default: 1 | |
# Only keep the latest 10 history to limit repo size | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
architecture: x64 | |
- name: Check build env | |
run: | | |
echo "pwd: $(pwd)" | |
echo "USER: $USER" | |
echo "HOME: $HOME" | |
echo "SHELL: $SHELL" | |
echo "PATH: $PATH" | |
df -h | |
os=$(uname -s) # OS | |
if [ "$os" = "Darwin" ]; then | |
sysctl -n machdep.cpu.brand_string | |
else | |
cat /proc/cpuinfo | |
vmstat -S M | |
fi | |
python3 --version | |
pip3 --version | |
mkdir -p cache | |
ls -lh cache | |
- name: Setup | |
run: | | |
# pip install binary to $HOME/.local/bin | |
# export PATH="$PATH:$HOME/.local/bin" | |
# | |
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path | |
echo "/home/runner/.local/bin" >> $GITHUB_PATH | |
pip3 install -r requirements.txt | |
- name: Process lists | |
run: | | |
ls -l | |
./scripts/get_top1m.sh | |
./scripts/process.py | |
- name: Check output | |
run: | | |
ls -lh out | |
./scripts/summary.sh > out/summary.txt | |
cat out/summary.txt | |
- name: Git config | |
run: | | |
git config --local user.email "CD@github-action" | |
git config --local user.name "GitHub Action" | |
- name: Commit changes on release branch | |
run: | | |
git checkout --orphan release | |
ls -l | |
rm -fr lists | |
mkdir -p lists | |
cp -fv out/lists.json out/*.zip out/summary.txt lists/ | |
now=$(date +%s) | |
echo $now > index.html | |
git add lists LICENSE-CC-BY-3.0.txt index.html | |
git commit -m "Update lists to $now" lists LICENSE-CC-BY-3.0.txt index.html | |
echo "now=$now" | |
- name: Force push data branch changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# branch: ${{ github.ref }} | |
branch: release | |
force: true |