Skip to content

[Core] add Github Action for Generate AppHeaders (figlet remove part 1) #1382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/generate-app-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

output_file="./misc/.app-headers"
> "$output_file" # Clear or create the file

current_date=$(date +"%m-%d-%Y")
# Header with date
{
echo "### Generated on $current_date"
echo "##################################################"
echo
} >> "$output_file"

# Find only regular .sh files in ./ct, sort them alphabetically
find ./ct -type f -name "*.sh" | sort | while read -r script; do
# Extract the APP name from the APP line
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)

if [[ -n "$app_name" ]]; then
# Generate figlet output
figlet_output=$(figlet -f slant "$app_name")
{
echo "### $(basename "$script")"
echo "APP=$app_name"
echo "$figlet_output"
echo
} >> "$output_file"
else
echo "No APP name found in $script, skipping."
fi
done

echo "Generated combined file at $output_file"
41 changes: 41 additions & 0 deletions .github/workflows/generate-app-headers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update .app-headers in /misc

on:
push:
branches: ["main"]
workflow_dispatch:

jobs:
update-combined:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CREATE_HEADER_APP_ID }}
private-key: ${{ CREATE_HEADER_SECRET }}

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Figlet
run: sudo apt-get install -y figlet

- name: Run generate-app-headers script
run: |
bash .github/workflows/generate-app-headers.sh

- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./misc/.app-headers
git commit -m "Update .app-headers in /misc" || echo "No changes to commit"
git push origin main
Loading