diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..d97606c --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,67 @@ +# Auto Push Workflow - Hướng dẫn sử dụng + +## Mô tả +Workflow này cho phép bạn tự động commit và push các thay đổi trong dự án WacWac chỉ bằng một cú nhấp chuột. + +## Cách sử dụng + +### 1. Kích hoạt workflow thủ công +1. Vào trang repository GitHub của bạn: https://github.com/Salt05/WacWac +2. Click vào tab **Actions** +3. Chọn workflow **Auto Push Data** từ danh sách bên trái +4. Click nút **Run workflow** (màu xanh) +5. (Tùy chọn) Nhập commit message tùy chỉnh hoặc để mặc định +6. Click **Run workflow** để bắt đầu + +### 2. Workflow sẽ tự động: +- Kiểm tra các thay đổi trong repository +- Commit tất cả các thay đổi với message bạn đã nhập +- Push code lên GitHub +- Thông báo nếu không có thay đổi nào + +## Tính năng +- ✅ Kích hoạt thủ công khi cần +- ✅ Tùy chỉnh commit message +- ✅ Tự động phát hiện thay đổi +- ✅ Push an toàn lên GitHub +- ✅ Thông báo rõ ràng về trạng thái + +## Lưu ý +- Workflow này sẽ commit **tất cả** các thay đổi trong repository +- Đảm bảo bạn có quyền push vào branch hiện tại +- Workflow chỉ chạy khi bạn kích hoạt thủ công + +--- + +# Auto Push Workflow - Usage Guide + +## Description +This workflow allows you to automatically commit and push changes in the WacWac project with just one click. + +## How to Use + +### 1. Manually trigger the workflow +1. Go to your GitHub repository page: https://github.com/Salt05/WacWac +2. Click on the **Actions** tab +3. Select the **Auto Push Data** workflow from the left sidebar +4. Click the **Run workflow** button (green) +5. (Optional) Enter a custom commit message or leave the default +6. Click **Run workflow** to start + +### 2. The workflow will automatically: +- Check for changes in the repository +- Commit all changes with your specified message +- Push the code to GitHub +- Notify if there are no changes + +## Features +- ✅ Manual trigger when needed +- ✅ Customizable commit message +- ✅ Automatic change detection +- ✅ Safe push to GitHub +- ✅ Clear status notifications + +## Notes +- This workflow will commit **all** changes in the repository +- Make sure you have push permissions to the current branch +- The workflow only runs when you manually trigger it diff --git a/.github/workflows/auto-push.yml b/.github/workflows/auto-push.yml new file mode 100644 index 0000000..4988b9c --- /dev/null +++ b/.github/workflows/auto-push.yml @@ -0,0 +1,53 @@ +name: Auto Push Data + +# This workflow can be manually triggered to commit and push any changes +on: + workflow_dispatch: + inputs: + commit_message: + description: 'Commit message for the changes' + required: false + default: 'Auto-update data' + +jobs: + auto-push: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Check for changes + id: check_changes + run: | + if [[ -n $(git status --porcelain) ]]; then + echo "changes=true" >> $GITHUB_OUTPUT + echo "Found changes to commit" + else + echo "changes=false" >> $GITHUB_OUTPUT + echo "No changes to commit" + fi + + - name: Commit and push changes + if: steps.check_changes.outputs.changes == 'true' + env: + COMMIT_MESSAGE: ${{ github.event.inputs.commit_message }} + run: | + git add . + git commit -m "$COMMIT_MESSAGE" + git push origin ${{ github.ref }} + + - name: No changes message + if: steps.check_changes.outputs.changes == 'false' + run: | + echo "✓ No changes detected. Repository is up to date."