换一个AI生成action

This commit is contained in:
zhiyi
2024-10-03 02:38:11 +08:00
parent 07dbe8f0c6
commit 936039ad38

View File

@@ -1,42 +1,42 @@
name: Auto Release on Specific File Update name: Auto Generate Release
on: on:
push:
workflow_dispatch: workflow_dispatch:
push:
paths:
- 'gfw.pac' # 替换为你要监控的文件路径
jobs: jobs:
release: generate-release:
if: ${{ github.event.head_commit.modified.includes('gfw.pac') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Get commit count for today - name: Set up Git
id: commit_count run: |
run: | git config --global user.name "GitHub Actions"
echo "COMMIT_COUNT=$(git rev-list --count HEAD --since=$(date -I) && echo '.${{ github.run_number }}')" >> $GITHUB_OUTPUT git config --global user.email "actions@github.com"
- name: Create release - name: Get commit count for today
id: create_release id: commit_count
uses: actions/create-release@v1 run: |
env: today=$(date +%Y%m%d)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} commit_count=$(git log --since="$today 00:00:00" --until="$today 23:59:59" --pretty=format: --name-only | grep -c '^gfw.pac$')
with: echo "::set-output name=commit_count::${commit_count}"
tag_name: ${{ github.ref_name }}
release_name: ${{ format('{}{}', (date +%Y%m%d), steps.commit_count.outputs.COMMIT_COUNT) }}
- name: Get changed file path - name: Create Release
id: changed_file_path id: create_release
run: | uses: softprops/action-gh-release@v1
CHANGED_FILE=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -m 1 gfw.pac) with:
echo "CHANGED_FILE_PATH=$CHANGED_FILE" >> $GITHUB_OUTPUT tag_name: v$(date +%Y%m%d).${{ steps.commit_count.outputs.commit_count }}
release_name: $(date +%Y%m%d).${{ steps.commit_count.outputs.commit_count }}
body: "Automatically generated release for file update"
draft: false
prerelease: false
files: gfw.pac # 替换为你要上传的文件路径
- name: Upload file as release asset - name: Verify Release
uses: actions/upload-release-asset@v1 run: |
env: echo "Release created with tag: v$(date +%Y%m%d).${{ steps.commit_count.outputs.commit_count }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.changed_file_path.outputs.CHANGED_FILE_PATH }}
asset_name: ${{ steps.changed_file_path.outputs.CHANGED_FILE_PATH | split("/") | last }}