Skip to content

update

update #31

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 =====