Download and Commit Files #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Download and Commit Files | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
download_and_commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Clean resources folder | |
run: | | |
mkdir -p resources | |
rm -rf resources/* | |
- 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 | |
- 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 | |
- 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 | |
- name: Configure Git | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "actions@github.com" | |
- name: Pull remote changes | |
run: | | |
git pull origin main | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
run: | | |
git add resources/* | |
git diff --cached --exit-code || git commit -m "Auto-update: $(date +"%Y-%m-%d %H:%M:%S")" | |
git push "https://${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" HEAD:main |