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