generated from CCA-Software-Group/py_template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
77 lines (65 loc) · 2.82 KB
/
update_stats.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
75
76
77
name: Update cache branch
# on: push
on:
schedule:
# workflow may be delayed for longer when it's on the hour
- cron: "20 07 * * *"
# allow manual triggering of workflow
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: (github.repository == 'astropy/repo_stats')
permissions:
contents: write
steps:
- name: Check out repo
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.11
- name: Display system info
run: |
python -c "import os; os.getcwd()"
python -c "import sys; print(sys.version)"
- name: Install package
run: |
pip install setuptools --upgrade
pip install .
# 10/11/2024: skipping cache save/restore as the cache isn't being properly restored,
# and this only takes a few minutes to run
# cache key syntax: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#using-contexts-to-create-cache-keys
# - name: Restore cached files
# id: cache-files-restore
# uses: actions/cache/restore@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
# with:
# path: ./cache
# key: ${{ runner.os }}-${{ hashFiles('~/.cache_key') }}
- name: Run update script
run: |
python -m repo_stats.runner -a ${{ secrets.ADS_TOKEN }} -g ${{ secrets.GIT_TOKEN }} -c "cache"
# caches are immutable, so create a new one (new key) each time any of the files being cached change.
# the cache key will be new if any files in the cache path have been changed by 'repo_stats.runner'.
# otherwise the cache save will 'fail' (because there's no need to update it - that's fine)
# - name: Update cached files
# id: cache-files-save
# uses: actions/cache/save@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
# with:
# path: ./cache
# key: ${{ runner.os }}-${{ hashFiles('./cache') }}
# - name: Save cache key
# run: |
# echo ${{ hashFiles('./cache') }} >> ~/.cache_key
- name: Create and push to orphan branch 'cache'
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git config --global user.name "github-actions-bot"
git config --global user.email "[email protected]"
git checkout --orphan cache
git rm -rf .
git add cache
git commit -m "update cache"
git push -f --set-upstream origin cache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}