Add monthly iso build workflow that can be triggered manually
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
name: Scheduled ArchISO Build
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 1 * *" # Runs monthly on the 1st day of the month
|
||||
workflow_dispatch: # Allows manual triggers (multiple times a month)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest # Ensure this runner has archiso capabilities
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install archiso and dependencies
|
||||
run: |
|
||||
sudo pacman -Syu --noconfirm archiso
|
||||
|
||||
- name: Build Arch ISO
|
||||
run: |
|
||||
# Replace 'releng' with your custom profile directory if needed
|
||||
sudo mkarchiso -v -w work -o out/ releng
|
||||
|
||||
- name: Generate Unique Dynamic Tag
|
||||
id: tag
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
run: |
|
||||
BASE_DATE=$(date -u +'%Y.%m.%d')
|
||||
REVISION=1
|
||||
TAG_NAME="iso-${BASE_DATE}-r${REVISION}"
|
||||
|
||||
# Check if the tag already exists via Gitea API, increment revision loop if it does
|
||||
while curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" \
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/releases/tags/$TAG_NAME" | grep -q "200"; do
|
||||
REVISION=$((REVISION + 1))
|
||||
TAG_NAME="iso-${BASE_DATE}-r${REVISION}"
|
||||
done
|
||||
|
||||
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
|
||||
echo "release_name=Arch Linux ISO (${BASE_DATE} Rev ${REVISION})" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release and Upload ISO
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.tag.outputs.tag_name }}
|
||||
name: ${{ steps.tag.outputs.release_name }}
|
||||
files: out/*.iso
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Keep only latest 3 releases
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
run: |
|
||||
# Fetch all releases
|
||||
releases=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/releases")
|
||||
|
||||
# Sort by creation date and delete old ones, keeping only the 3 newest releases
|
||||
echo "$releases" | jq -r 'sort_by(.created_at) | .[].id' | head -n -3 | while read -r id; do
|
||||
if [ -n "$id" ]; then
|
||||
echo "Deleting old release ID: $id"
|
||||
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" \
|
||||
"$SERVER_URL/api/v1/repos/$REPOSITORY/releases/$id"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user