Skip to content

Download and Commit Files #1

Download and Commit Files

Download and Commit Files #1

Workflow file for this run

name: Download and Commit Files
on:
schedule:
# Har kuni soat 00:00 da ishga tushadi
- cron: "0 0 * * *"
jobs:
download_and_commit:
runs-on: ubuntu-latest
steps:
# Repository-ni checkout qilish
- name: Checkout repository
uses: actions/checkout@v3
# Resources papkasidagi eski fayllarni o'chirish
- name: Clean resources folder
run: |
mkdir -p resources
rm -rf resources/*
# CSV faylni yuklab olish
- name: Download CSV file
run: |
curl -o resources/bad_words.csv ${{ secrets.CSV_FILE_URL }}
if [ ! -s resources/bad_words.csv ]; then
echo "CSV file download failed!" && exit 1
fi
# JSON faylni yuklab olish
- name: Download JSON file
run: |
curl -o resources/bad_words.json ${{ secrets.JSON_FILE_URL }}
if [ ! -s resources/bad_words.json ]; then
echo "JSON file download failed!" && exit 1
fi
# XLSX faylni yuklab olish
- name: Download XLSX file
run: |
curl -o resources/bad_words.xlsx ${{ secrets.XLSX_FILE_URL }}
if [ ! -s resources/bad_words.xlsx ]; then
echo "XLSX file download failed!" && exit 1
fi
# Remote branchdan o'zgarishlarni olish (pull qilish)
- name: Pull remote changes
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git stash --include-untracked
git pull --rebase origin main
git stash pop || echo "No stash to apply"
# O'zgarishlarni repositoryga qo'shish
- name: Commit and push changes
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git add resources/*
git commit -m "Auto-update: $(date +"%Y-%m-%d %H:%M:%S")" || echo "No changes to commit"
git push "https://${GH_PAT}@github.com/${{ github.repository }}.git" HEAD:main