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 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create archives | |
run: | | |
# ... (lệnh tar để nén file) ... | |
for dir in */; do | |
if [ "$dir" == ".github/" ]; then continue; fi | |
ARCHIVE_NAME="${dir%/}.tar.gz" | |
tar -czvf "${ARCHIVE_NAME}" --exclude='README.md' "${dir}" | |
done | |
# BƯỚC NÀY RẤT QUAN TRỌNG, KHÔNG ĐƯỢC XÓA | |
- name: Get latest release | |
id: get_latest_release | |
uses: pozetroninc/[email protected] | |
with: | |
repository: ${{ github.repository }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Bước này cần 'upload_url' từ bước trên | |
- 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 | |
asset_content_type: application/gzip |