-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (62 loc) · 2.65 KB
/
watch.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
name: run
on:
workflow_dispatch:
schedule:
- cron: "15 2,8,14,20 * * *"
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ARTIFACT_URL=$(gh api -q '.artifacts[0].archive_download_url' /repos/${{ github.repository }}/actions/artifacts)
[ ! -z "${ARTIFACT_URL}" ] && curl -sLo artifact.zip -H "Authorization: token ${GH_TOKEN}" ${ARTIFACT_URL}
[ -f artifact.zip ] && file artifact.zip && unzip artifact.zip && rm artifact.zip
- name: Install prerequsites
run: pip3 install -r requirements.txt
- name: Checkout watch repository
# Work-around secrets not accessible in conditionals as per https://github.com/actions/runner/issues/520
env:
SOURCEMON_WATCH_REPO: ${{ secrets.SOURCEMON_WATCH_REPO }}
if: ${{ env.SOURCEMON_WATCH_REPO != null }}
uses: actions/checkout@v4
with:
repository: ${{ secrets.SOURCEMON_WATCH_REPO }}
ssh-key: ${{ secrets.SOURCEMON_WATCH_REPO_KEY || '' }}
token: ${{ secrets.SOURCEMON_WATCH_REPO_TOKEN || github.token }}
path: watches
- name: Checkout watch data repository
# Work-around secrets not accessible in conditionals as per https://github.com/actions/runner/issues/520
env:
SOURCEMON_WATCHDATA_REPO: ${{ secrets.SOURCEMON_WATCHDATA_REPO }}
if: ${{ env.SOURCEMON_WATCHDATA_REPO != null }}
uses: actions/checkout@v4
with:
repository: ${{ secrets.SOURCEMON_WATCHDATA_REPO }}
ssh-key: ${{ secrets.SOURCEMON_WATCHDATA_REPO_KEY || '' }}
token: ${{ secrets.SOURCEMON_WATCHDATA_REPO_TOKEN || github.token }}
path: watch-data
- name: Execute watch
run: python3 ./watch.py --cache ./cache.tar.gz ./watches/
- name: Commit watch data repository
# Work-around secrets not accessible in conditionals as per https://github.com/actions/runner/issues/520
env:
SOURCEMON_WATCHDATA_REPO: ${{ secrets.SOURCEMON_WATCHDATA_REPO }}
if: ${{ env.SOURCEMON_WATCHDATA_REPO != null }}
run: |
pushd watch-data
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add -A
git commit --allow-empty -m "Watch $(date +%s)"
git push
popd
- uses: actions/upload-artifact@v4
with:
name: cache.tar.gz
path: ./cache.tar.gz
retention-days: 7