Skip to content

Create tar.gz Folders for Latest Release #30

Create tar.gz Folders for Latest Release

Create tar.gz Folders for Latest Release #30

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ừ các file không cần thiết
# tar -czvf [tên-file-output] [thư-mục-cần-nén] --exclude='[file-cần-loại-bỏ]'
tar -czvf "${ARCHIVE_NAME}" \
--exclude='.github' \
--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 }}
- name: Upload archives to latest release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.get_latest_release.outputs.upload_url }}
asset_path: ./*.tar.gz # Upload tất cả các file .tar.gz trong thư mục gốc
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:

Check failure on line 57 in .github/workflows/zip-and-release.yml

View workflow run for this annotation

GitHub Actions / Create and Upload Release Archive

Invalid workflow file

The workflow is not valid. .github/workflows/zip-and-release.yml (Line: 57, Col: 9): Unexpected value 'strategy'
matrix:
asset_name: ${{ toJSON(fromJSON('{"include":' + toJSON(steps.get_latest_release.outputs.assets.*.name) + '}').include) }}