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: Create and Upload Release Archive | |
# Kích hoạt workflow này khi có push vào nhánh main hoặc có thể kích hoạt thủ công | |
on: | |
push: | |
branches: | |
- main # Thay 'main' bằng nhánh mặc định của bạn nếu cần | |
workflow_dispatch: # Cho phép kích hoạt thủ công từ tab Actions | |
jobs: | |
build_and_upload: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # Cần quyền ghi để tạo release và upload assets | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create archives for each directory | |
run: | | |
# Lặp qua tất cả các thư mục trong thư mục gốc | |
for dir in */; do | |
# Bỏ qua thư mục .github | |
if [ "$dir" == ".github/" ]; then | |
continue | |
fi | |
# Tên file nén sẽ là tên thư mục | |
ARCHIVE_NAME="${dir%/}.tar.gz" | |
echo "Compressing ${dir} to ${ARCHIVE_NAME}" | |
# Nén thư mục, loại trừ file README.md | |
tar -czvf "${ARCHIVE_NAME}" \ | |
--exclude='README.md' \ | |
"${dir}" | |
done | |
- name: Get latest release | |
id: get_latest_release | |
uses: pozetroninc/[email protected] | |
with: | |
repository: ${{ github.repository }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# ===== KHỐI MÃ ĐÃ SỬA LỖI BẮT ĐẦU TỪ ĐÂY ===== | |
- name: Upload archives to latest release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_latest_release.outputs.upload_url }} | |
asset_path: ./*.tar.gz # Dùng glob pattern để upload tất cả các file .tar.gz | |
asset_content_type: application/gzip | |
# ===== KẾT THÚC KHỐI MÃ SỬA LỖI ===== |