Skip to content

Commit

Permalink
ci: update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianosrp committed Aug 17, 2024
1 parent 2197716 commit 18e4954
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/update-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

schedule:
- cron: '0 8 * * *'
- cron: "0 8 * * *"

workflow_dispatch:

Expand All @@ -15,20 +15,26 @@ jobs:
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.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.lock
- name: Run Python script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python src/open_source_aviation/data.py
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install -r requirements.lock
- name: Update Tabl
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
python src/open_source_aviation/data.py
git add README.md
git commit -m "Update Table"
git push
14 changes: 3 additions & 11 deletions src/open_source_aviation/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ class GitHubDatData(GitHubData):
datas = [GitHubCSVData(f), GitHubDatData(f)]
df = pd.concat(
[
pd.DataFrame(data.get_info()).sort_values("last_modified", ascending=False)
pd.DataFrame(data.get_info()).sort_values(
"last_modified", ascending=False
)
for data in datas
],
axis=0,
Expand All @@ -122,13 +124,3 @@ class GitHubDatData(GitHubData):
push = True
break
line = f.readline()

if push:
# Commit and push
current_repo = Repo(Path.cwd())
current_repo.index.add(["README.md"])
current_repo.index.commit(
f"Auto: {datetime.datetime.now():%F} - Update data metadata"
)
origin = current_repo.remote(name="origin")
origin.push()

0 comments on commit 18e4954

Please sign in to comment.