diff --git a/.github/workflows/App_Header_Merge_Into_main.yaml b/.github/workflows/App_Header_Merge_Into_main.yaml deleted file mode 100644 index 0c9f5332..00000000 --- a/.github/workflows/App_Header_Merge_Into_main.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: Auto Update .app-headers and Create PR - -on: - push: - branches: - - main - paths: - - 'ct/**.sh' - -jobs: - update-app-headers: - runs-on: ubuntu-latest - steps: - # Step 1: Checkout the repository - - name: Checkout repository - uses: actions/checkout@v2 - - # Step 2: Set up Git user for committing changes - - name: Set up Git - run: | - git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" - - # Step 3: Ensure .app-headers file exists - - name: Ensure .app-headers file exists - run: | - if [ ! -f ct/.app-headers ]; then - echo "Creating .app-headers file." - touch ct/.app-headers - fi - - # Step 4: Process the ct/*.sh files and update .app-headers - - name: Update .app-headers with figlet output - run: | - echo "Updating .app-headers with figlet output." - for script in ct/*.sh; do - if grep -q 'APP=' "$script"; then - APP_NAME=$(grep -oP 'APP=\K\w+' "$script") - echo "Processing $script for APP: \"$APP_NAME\"" - figlet "$APP_NAME" >> ct/.app-headers - fi - done - - # Step 5: Check out and merge main into the update-app-headers branch without committing - - name: Merge main into update-app-headers - run: | - git fetch origin - git checkout update-app-headers - git merge origin/main --no-ff --no-commit -m "Merge main into update-app-headers" - echo "Merge complete. Please review and commit the changes manually." - - # Step 6: Check if a PR exists and create one if it doesn't - - name: Create Pull Request if not exists - run: | - PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number') - - if [ -z "$PR_EXISTS" ]; then - echo "Creating a new PR." - PR_URL=$(gh pr create --title "[core]: update .app-headers to latest version" \ - --body "This PR automatically updates the .app-headers file." \ - --head update-app-headers \ - --base main) - echo "PR created: $PR_URL" - else - echo "PR already exists." - fi diff --git a/.github/workflows/auto-update-app-headers.yml b/.github/workflows/auto-update-app-headers.yml new file mode 100644 index 00000000..2cb21c55 --- /dev/null +++ b/.github/workflows/auto-update-app-headers.yml @@ -0,0 +1,63 @@ +name: Auto Update .app-headers with Hard Merge from Main + +on: + push: + branches: + - main + paths: + - 'ct/**.sh' + +jobs: + auto-update: + runs-on: ubuntu-latest + steps: + # Step 1: Checkout repository + - name: Checkout repository + uses: actions/checkout@v2 + + # Step 2: Set up Git user + - name: Set up Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + # Step 3: Reset update-app-headers to main + - name: Reset update-app-headers branch to main + run: | + git checkout -B update-app-headers origin/main + echo "Branch update-app-headers reset to match main" + + # Step 4: Ensure .app-headers file exists + - name: Ensure .app-headers file exists + run: | + touch ct/.app-headers + + # Step 5: Update .app-headers with figlet output + - name: Update .app-headers + run: | + output_file="./ct/.app-headers" + > "$output_file" # Clear or create the file + + current_date=$(date +"%m-%d-%Y") + echo "### Generated on $current_date" >> "$output_file" + echo "##################################################" >> "$output_file" + echo >> "$output_file" + + find ./ct -type f -name "*.sh" | sort | while read -r script; do + app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null) + + if [[ -n "$app_name" ]]; then + figlet_output=$(figlet -f slant "$app_name" 2>/dev/null || echo "FIGLET ERROR: $app_name") + echo "### $(basename "$script")" >> "$output_file" + echo "APP=$app_name" >> "$output_file" + echo "$figlet_output" >> "$output_file" + echo >> "$output_file" + fi + done + + # Step 6: Commit and push changes + - name: Commit and push changes + run: | + git add ct/.app-headers + git commit -m "Update .app-headers on $(date +"%Y-%m-%d")" || echo "No changes to commit" + git push --force origin update-app-headers