[mefinity] Update #47
This file contains 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: Update Domain | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
copy_domains: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Set up Git | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "GitHub Actions" | |
git remote set-url origin "https://${{ secrets.GH_TOKEN }}@github.com/lepasid/blocklist.git" | |
- name: Set up time zone | |
run: echo "TZ=Asia/Jakarta" >> $GITHUB_ENV | |
- name: Copy and rename domains file | |
run: | | |
FILE_NAME=$(date +"%Y-%m-%d") | |
cp domains "$FILE_NAME" | |
- name: Remove existing date file if exists | |
run: | | |
FILE_NAME=$(date +"%Y-%m-%d") | |
if [ -f "$FILE_NAME" ]; then | |
rm "$FILE_NAME" | |
fi | |
- name: Checkout or create 2024 branch | |
run: | | |
git fetch origin | |
if git rev-parse --verify origin/2024; then | |
git checkout 2024 | |
git pull origin 2024 | |
else | |
git checkout -b 2024 | |
fi | |
- name: Copy and commit new file | |
run: | | |
FILE_NAME=$(date +"%Y-%m-%d") | |
cp domains "$FILE_NAME" | |
git add "$FILE_NAME" | |
git commit -m "Update $FILE_NAME" --allow-empty | |
- name: Push changes to 2024 branch | |
run: | | |
git push origin 2024 |