-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.69 KB
/
fetch_iss_tle.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
name: Fetch ISS TLE
on:
schedule:
- cron: '0 1-23/6 * * *' # Starts at 1 AM UTC and runs every 6 hours
workflow_dispatch: # Allow manual triggering if needed
jobs:
fetch-tle:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Run TLE Fetch Script
run: |
python scripts/fetch_tle.py
- name: Update README with TLE count
run: |
# Get the number of TLEs using jq
num_tles=$(jq '. | length' iss_tle.json)
# Update or add the "Number of TLEs" line in README.md
if grep -q '^Number of TLEs:' README.md; then
# Update the existing line
sed -i "s/^Number of TLEs:.*/Number of TLEs: ${num_tles}/" README.md
else
# Add a new line if not present
echo >> README.md
echo "Number of TLEs: ${num_tles}" >> README.md
fi
- name: Commit changes
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
# Check if there are changes to commit
if ! git diff --exit-code iss_tle.json; then
git add iss_tle.json README.md
git commit -m "Update ISS TLE and README with TLE count"
git push
else
echo "No changes to commit."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}