-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (81 loc) · 2.79 KB
/
fps_update.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Update FPS Shops Data
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
workflow_dispatch:
push:
jobs:
update_fps_shops:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache pip dependencies
uses: actions/cache@v4
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install aiohttp pandas
- name: Download previous release artifact
run: |
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest)
asset_url=$(echo $latest_release | jq -r '.assets[0].browser_download_url')
if [ "$asset_url" != "null" ]; then
curl -L -o previous_ConsolidatedShops.csv $asset_url
echo "Previous artifact downloaded."
else
echo "No previous release found."
fi
- name: Run FPS data extraction and comparison
run: |
python script.py
if [ -f "previous_ConsolidatedShops.csv" ]; then
python compare_data.py || echo "changes=N/A" >> $GITHUB_ENV
else
echo "No previous data found. Skipping comparison."
echo "changes=N/A" >> $GITHUB_ENV
fi
- name: Check for changes
run: |
if [ "${{ env.changes }}" != "N/A" ] && \
echo "${{ env.changes }}" | grep -q "Added Shops: 0" && \
echo "${{ env.changes }}" | grep -q "Removed Shops: 0" && \
echo "${{ env.changes }}" | grep -q "Updated Shops: 0"; then
echo "no_changes=true" >> $GITHUB_ENV
fi
env:
changes: ${{ steps.compare-data.outputs.changes }}
- name: Upload ConsolidatedShops.csv artifact
if: env.no_changes != 'true'
uses: actions/upload-artifact@v4
with:
name: ConsolidatedShops.csv
path: ConsolidatedShops.csv
- name: Set tag name to current timestamp
run: |
NOW=$(date +'%Y%m%d%H%M%S')
TAG_NAME="v${NOW}"
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Create release with notes
if: env.no_changes != 'true'
uses: softprops/action-gh-release@v2
with:
files: ConsolidatedShops.csv
tag_name: "${{ env.TAG_NAME }}"
make_latest: true
body: |
Daily update of FPS Shops data.
Changes:
${{ steps.compare-data.outputs.changes }}
token: ${{ secrets.GITHUB_TOKEN }}