Skip to content

Commit cdd68a0

Browse files
authored
update
1 parent 3b1e366 commit cdd68a0

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed
Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,67 @@
1-
name: Create tar.gz Folders for Latest Release
1+
name: Compile SELinux Policy
22

33
on:
4-
workflow_dispatch:
54
push:
65
branches:
7-
- main # Trigger khi có thay đổi trên branch chính
8-
tags:
9-
- 'v*' # Trigger khi có tag mới
6+
- main
7+
paths:
8+
- 'logrotate/selinux-policy/ee-logrotate.te'
9+
- '.github/workflows/compile-selinux-policy.yml'
10+
workflow_dispatch:
1011

1112
jobs:
12-
build-and-upload:
13+
compile-policy:
14+
# Sử dụng container Fedora để có sẵn các công cụ SELinux
15+
container: fedora:latest
1316
runs-on: ubuntu-latest
1417
permissions:
1518
contents: write
1619

1720
steps:
1821
- name: Checkout repository
1922
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0 # Needed to get all tags for version comparison
2223

24+
- name: Install SELinux build tools and Git
25+
# Cài đặt các gói cần thiết và cả git trong container Fedora
26+
run: dnf install -y policycoreutils-devel selinux-policy-devel make git
27+
28+
- name: Compile and package SELinux policy
29+
run: |
30+
# Di chuyển vào thư mục chứa file .te
31+
cd logrotate/selinux-policy/
32+
33+
# Bước 1: Biên dịch file .te thành .mod
34+
echo "Compiling ee-logrotate.te to ee-logrotate.mod..."
35+
# Đổi tên file đầu ra để khớp với tên module bên trong file .te
36+
checkmodule -M -m -o ee-logrotate.mod ee-logrotate.te
37+
38+
# Bước 2: Tạo policy package (.pp) từ file .mod
39+
echo "Creating ee-logrotate.pp from ee-logrotate.mod..."
40+
semodule_package -o ee-logrotate.pp -m ee-logrotate.mod
41+
42+
# Thêm một bước để lấy thông tin tag mới nhất, vì upload release cần tag
2343
- name: Get the latest tag
2444
id: get_tag
2545
run: |
2646
latest_tag=$(git describe --tags --abbrev=0)
2747
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
2848
echo "📌 Latest tag: ${latest_tag}"
2949
30-
- name: Create tar.gz archives from each directory
31-
run: |
32-
for dir in */; do
33-
dirname="${dir%/}"
34-
if [ "$dirname" == ".github" ]; then
35-
echo "⏩ Skipping .github directory"
36-
continue
37-
fi
38-
echo "📦 Creating '${dirname}.tar.gz'..."
39-
tar --exclude="${dirname}/README.md" -czf "${dirname}.tar.gz" "$dirname"
40-
done
41-
42-
- name: Upload tar.gz files to release
50+
# Thêm bước này để tải file .pp lên GitHub Release
51+
- name: Upload compiled policy file to release
4352
env:
4453
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4554
run: |
46-
gh release upload ${{ steps.get_tag.outputs.latest_tag }} *.tar.gz --clobber
47-
echo "✅ Successfully uploaded tar.gz files to release '${{ steps.get_tag.outputs.latest_tag }}'"
55+
# Di chuyển file .pp về thư mục gốc để dễ dàng upload
56+
mv logrotate/selinux-policy/ee-logrotate.pp .
57+
# Đổi tên file để tải lên khớp với tên mới
58+
gh release upload ${{ steps.get_tag.outputs.latest_tag }} ee-logrotate.pp --clobber
59+
echo "✅ Successfully uploaded ee-logrotate.pp to release '${{ steps.get_tag.outputs.latest_tag }}'"
4860
49-
- name: Clean up artifacts
50-
run: rm -f *.tar.gz
61+
# Xóa bước upload artifact cũ
62+
# - name: Upload compiled policy file
63+
# uses: actions/upload-artifact@v4
64+
# with:
65+
# name: compiled-selinux-policy
66+
# path: ee-logrotate.pp
67+
# retention-days: 5

0 commit comments

Comments
 (0)