Compile SELinux Policy #7
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: Compile SELinux Policy | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'logrotate/selinux-policy/ee-logrotate.te' | |
- '.github/workflows/compile-selinux-policy.yml' | |
workflow_dispatch: | |
jobs: | |
compile-policy: | |
# Chạy trên máy chủ Ubuntu mặc định, không dùng container | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
# Bước này sẽ tải code về và bao gồm lịch sử Git đầy đủ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install SELinux build tools and Git | |
# Cài đặt các gói cần thiết bằng apt-get trên Ubuntu | |
run: sudo apt-get update && sudo apt-get install -y policycoreutils selinux-policy-dev make git | |
- name: Compile and package SELinux policy | |
run: | | |
# Di chuyển vào thư mục chứa file .te | |
cd logrotate/selinux-policy/ | |
# Bước 1: Biên dịch file .te thành .mod | |
echo "Compiling ee-logrotate.te to ee-logrotate.mod..." | |
checkmodule -M -m -o ee-logrotate.mod ee-logrotate.te | |
# Bước 2: Tạo policy package (.pp) từ file .mod | |
echo "Creating ee-logrotate.pp from ee-logrotate.mod..." | |
semodule_package -o ee-logrotate.pp -m ee-logrotate.mod | |
- name: Get the latest tag | |
id: get_tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT | |
echo "📌 Latest tag: ${latest_tag}" | |
- name: Upload compiled policy file to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Di chuyển file .pp về thư mục gốc để dễ dàng upload | |
mv logrotate/selinux-policy/ee-logrotate.pp . | |
gh release upload ${{ steps.get_tag.outputs.latest_tag }} ee-logrotate.pp --clobber | |
echo "✅ Successfully uploaded ee-logrotate.pp to release '${{ steps.get_tag.outputs.latest_tag }}'" |