Add Gitea Actions workflow to auto-generate build-info.php
This commit is contained in:
55
.gitea/workflows/generate-build-info.yml
Normal file
55
.gitea/workflows/generate-build-info.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Generate Build Info (Commit Hash)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Change to your actual production branch if
|
||||
different (e.g. master)
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build-info:
|
||||
runs-on: ubuntu-latest # Or 'self-hosted' / your runner's label if
|
||||
different
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Generate build-info.php
|
||||
run: |
|
||||
SHORT_HASH=$(git rev-parse --short HEAD)
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
|
||||
|
||||
mkdir -p dapper # Ensure folder exists
|
||||
|
||||
cat > dapper/build-info.php << EOF
|
||||
<?php
|
||||
// Auto-generated build metadata - DO NOT EDIT manually
|
||||
// Generated on: $DATE
|
||||
return [
|
||||
'commit' => '$SHORT_HASH',
|
||||
'branch' => '$BRANCH',
|
||||
'built' => '$DATE',
|
||||
];
|
||||
EOF
|
||||
|
||||
echo "Generated build-info.php with commit $SHORT_HASH"
|
||||
|
||||
- name: Commit build-info.php if changed
|
||||
uses: https://github.com/stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "chore: update build-info.php [ci skip]"
|
||||
file_pattern: dapper/build-info.php
|
||||
skip_fetch: true
|
||||
skip_checkout: true
|
||||
commit_user_name: "Automated Build"
|
||||
commit_user_email: "ampedlease@ampedlease.com"
|
||||
commit_author: "Automated Build <ampedlease@ampedlease.com>"
|
||||
Reference in New Issue
Block a user