75 lines
3.0 KiB
YAML
75 lines
3.0 KiB
YAML
name: Gitea Actions Demo
|
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
on:
|
|
pull_request:
|
|
branches: ["main"]
|
|
types: [closed]
|
|
push:
|
|
branches: [ "main","releases/**" ]
|
|
# paths:
|
|
# - 'sub-project/**'
|
|
# - '!sub-project/docs/**' # !在正匹配之后匹配负模式(以 为前缀)将排除该路径。
|
|
# paths-ignore:
|
|
# - 'docs/**'
|
|
# tags:
|
|
# - v2
|
|
# - v1.*
|
|
# schedule:
|
|
# - cron: '30 5 * * 1,3'
|
|
# - cron: '30 5 * * 2,4'
|
|
|
|
jobs:
|
|
Explore-Gitea-Actions:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Get commit message (Push)
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
echo "提交的信息: ${{ github.event.head_commit.message }}"
|
|
commit_title=$(git log -1 --pretty=format:"%s")
|
|
commit_body=$(git log -1 --pretty=format:"%b")
|
|
echo "Commit Title: $commit_title"
|
|
echo "Commit Body: $commit_body"
|
|
commit_name=$(git log -1 --pretty=format:"%an")
|
|
echo "Commit name: $commit_name"
|
|
commit_email=$(git log -1 --pretty=format:"%ae")
|
|
echo "作者邮箱: $commit_email"
|
|
commit_date=$(git log -1 --pretty=format:"%ci")
|
|
echo "作者提交时间: $commit_date"
|
|
commit_durl=$(git log -1 --pretty=format:"%cr")
|
|
echo "提交时长: $commit_durl"
|
|
commit_hash=$(git log -1 --pretty=format:"%H")
|
|
echo "提交Hash: $commit_hash"
|
|
if [[ "$commit_body" =~ "发布生产" ]]; then
|
|
echo '包含: if echo "$string1" | grep -q "$string2"; then'
|
|
exit 0
|
|
else
|
|
echo "不包含"
|
|
exit 1
|
|
fi
|
|
- name: Get commit message (Pull Request)
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
echo "是否是合并关闭的 $PR_STATUS_FLAG"
|
|
pr_num=${{ github.event.pull_request.number }}
|
|
git fetch origin refs/pull/${pr_num}/head:refs/remotes/origin/pull/${pr_num}/head
|
|
commit_title=$(git log -1 --pretty=format:"%s" origin/pull/${pr_num}/head)
|
|
commit_body=$(git log -1 --pretty=format:"%b" origin/pull/${pr_num}/head)
|
|
echo "合并请求 Commit Title: $commit_title"
|
|
echo "合并请求Commit Body: $commit_body"
|
|
env:
|
|
PR_STATUS_FLAG: ${{ github.event.pull_request.merged }}
|
|
|
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
|
- name: List files in the repository
|
|
run: |
|
|
ls ${{ gitea.workspace }}
|
|
- run: echo "🍏 This job's status is ${{ job.status }}." |