mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2025-09-09 01:22:41 +08:00
first commit
This commit is contained in:
@@ -0,0 +1,160 @@
|
|||||||
|
name: Build & Push Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ['Release']
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
actions: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux/amd64
|
||||||
|
os: ubuntu-latest
|
||||||
|
- platform: linux/arm64
|
||||||
|
os: ubuntu-24.04-arm
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Prepare platform name
|
||||||
|
run: |
|
||||||
|
echo "PLATFORM_NAME=${{ matrix.platform }}" | sed 's|/|-|g' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Checkout source code
|
||||||
|
run: |
|
||||||
|
git clone https://${{ secrets.REPO_URL }}.git .
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set lowercase repository owner
|
||||||
|
id: lowercase
|
||||||
|
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=raw,value=${{ env.latest_tag }},enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
run: |
|
||||||
|
echo "latest_tag=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[0].name // "latest"' | sed 's/^v//')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
tags: ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv:${{ env.latest_tag }}
|
||||||
|
outputs: type=image,name=ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv,name-canonical=true,push=true
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_NAME }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set lowercase repository owner
|
||||||
|
id: lowercase
|
||||||
|
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Get latest tag
|
||||||
|
run: |
|
||||||
|
echo "latest_tag=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[0].name // "latest"' | sed 's/^v//')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=raw,value=${{ env.latest_tag }},enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Create manifest list and push
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf 'ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv@sha256:%s ' *)
|
||||||
|
|
||||||
|
- name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ghcr.io/${{ steps.lowercase.outputs.owner }}/lunatv:${{ steps.meta.outputs.version }}
|
||||||
|
|
||||||
|
cleanup-refresh:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- merge
|
||||||
|
if: always() && github.event_name != 'pull_request_target'
|
||||||
|
steps:
|
||||||
|
- name: Delete workflow runs
|
||||||
|
uses: Mattraks/delete-workflow-runs@main
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
repository: ${{ github.repository }}
|
||||||
|
retain_days: 0
|
||||||
|
keep_minimum_runs: 2
|
||||||
|
- name: Refresh VERSION.txt cache
|
||||||
|
run: |
|
||||||
|
echo "Refreshing VERSION.txt cache..."
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/MoonTechLab/LunaTV/VERSION.txt
|
||||||
|
echo ""
|
||||||
|
echo "VERSION.txt cache refreshed successfully"
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
name: NoMore Spam
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
models: read
|
||||||
|
actions: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
spam-detection:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: NoMore Spam
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Fuck All the Shit
|
||||||
|
uses: JohnsonRan/nomore-spam@main
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
ai-base-url: ${{ secrets.AI_BASE_URL }}
|
||||||
|
ai-api-key: ${{ secrets.AI_API_KEY }}
|
||||||
|
ai-model: ${{ secrets.AI_MODEL }}
|
||||||
|
blacklist: ${{ secrets.BLACKLIST }}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
run: |
|
||||||
|
git clone https://${{ secrets.REPO_URL }}.git .
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
echo "Tag: $TAG_NAME"
|
||||||
|
|
||||||
|
- name: Get tag message
|
||||||
|
id: tag_message
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TAG_NAME=${{ steps.version.outputs.tag }}
|
||||||
|
RELEASE_BODY=$(gh release view "$TAG_NAME" --json body -q .body || echo "")
|
||||||
|
printf '%s\n' "$RELEASE_BODY" > /tmp/tag_message.txt
|
||||||
|
echo "Tag message saved to /tmp/tag_message.txt"
|
||||||
|
echo "Tag message content:"
|
||||||
|
cat /tmp/tag_message.txt
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Update version files and generate changelog
|
||||||
|
run: |
|
||||||
|
CURRENT_DATE=$(date +%Y-%m-%d)
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG_MESSAGE=$(cat /tmp/tag_message.txt)
|
||||||
|
echo "Updating CHANGELOG file..."
|
||||||
|
{
|
||||||
|
echo "## [$VERSION] - $CURRENT_DATE"
|
||||||
|
echo ""
|
||||||
|
cat /tmp/tag_message.txt
|
||||||
|
echo ""
|
||||||
|
} > /tmp/new_entry.txt
|
||||||
|
|
||||||
|
if [ -f "CHANGELOG" ]; then
|
||||||
|
cp CHANGELOG CHANGELOG.bak
|
||||||
|
cat /tmp/new_entry.txt CHANGELOG.bak > CHANGELOG
|
||||||
|
else
|
||||||
|
cp /tmp/new_entry.txt CHANGELOG
|
||||||
|
fi
|
||||||
|
echo "✅ Updated CHANGELOG with new entry for version $VERSION"
|
||||||
|
|
||||||
|
echo "Updating VERSION.txt..."
|
||||||
|
echo "$VERSION" > VERSION.txt
|
||||||
|
echo "✅ Updated VERSION.txt to $VERSION"
|
||||||
|
|
||||||
|
echo "Generating changelog TypeScript file..."
|
||||||
|
node scripts/convert-changelog.js
|
||||||
|
|
||||||
|
echo "Updating version.ts..."
|
||||||
|
sed -i "s/const CURRENT_VERSION = '[^']*';/const CURRENT_VERSION = '$VERSION';/" src/lib/version.ts
|
||||||
|
echo "✅ Updated version.ts to $VERSION"
|
||||||
|
|
||||||
|
- name: Commit generated files
|
||||||
|
run: |
|
||||||
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
git add CHANGELOG VERSION.txt src/lib/changelog.ts src/lib/version.ts
|
||||||
|
if git diff --staged --quiet; then
|
||||||
|
echo "No changes to commit"
|
||||||
|
else
|
||||||
|
git commit -m "chore: Bump to ${{ steps.version.outputs.version }}"
|
||||||
|
git push https://${{ secrets.PUSH_TOKEN }}@${{ secrets.REPO_URL }}.git HEAD:main
|
||||||
|
echo "Committed and pushed generated files"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user