Skip to content

Commit 910e767

Browse files
authored
Update auto-update-app-headers.yml
1 parent 8c54d25 commit 910e767

File tree

1 file changed

+31
-38
lines changed

1 file changed

+31
-38
lines changed

.github/workflows/auto-update-app-headers.yml

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,52 @@ on:
66
- main
77
paths:
88
- 'ct/**.sh'
9-
workflow_dispatch:
9+
workflow_dispatch: # Ermöglicht das manuelle Ausführen der Action
1010

1111
jobs:
12-
auto-update:
12+
update-app-headers:
1313
runs-on: ubuntu-latest
14+
1415
steps:
15-
# Step 1: Checkout repository
16+
# Step 1: Checkout the repository
1617
- name: Checkout repository
1718
uses: actions/checkout@v2
1819

19-
# Step 2: Set up Git user
20+
# Step 2: Set up Git user for committing changes
2021
- name: Set up Git
2122
run: |
2223
git config --global user.name "GitHub Actions"
2324
git config --global user.email "[email protected]"
2425
25-
# Step 3: Reset update-app-headers to main
26-
- name: Reset update-app-headers branch to main
26+
# Step 3: Create a new branch from main
27+
- name: Create a new branch based on main
2728
run: |
28-
git checkout -B update-app-headers origin/main
29-
echo "Branch update-app-headers reset to match main"
30-
31-
# Step 4: Ensure .app-headers file exists
32-
- name: Ensure .app-headers file exists
29+
git fetch origin
30+
git checkout main
31+
git pull origin main
32+
BRANCH_NAME="update-app-headers-$(date +'%Y-%m-%d-%H-%M-%S')"
33+
git checkout -b "$BRANCH_NAME"
34+
echo "Created and switched to branch $BRANCH_NAME"
35+
36+
# Step 4: Run the generate-app-headers.sh script to update .app-headers
37+
- name: Run generate-app-headers.sh to update .app-headers
3338
run: |
34-
touch ct/.app-headers
39+
chmod +x .github/workflows/generate-app-headers.sh
40+
.github/workflows/generate-app-headers.sh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3543

36-
# Step 5: Update .app-headers with figlet output
37-
- name: Update .app-headers
44+
# Step 5: Push changes to the new branch
45+
- name: Push changes to the new branch
3846
run: |
39-
output_file="./ct/.app-headers"
40-
> "$output_file" # Clear or create the file
41-
42-
current_date=$(date +"%m-%d-%Y")
43-
echo "### Generated on $current_date" >> "$output_file"
44-
echo "##################################################" >> "$output_file"
45-
echo >> "$output_file"
46-
47-
find ./ct -type f -name "*.sh" | sort | while read -r script; do
48-
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
49-
50-
if [[ -n "$app_name" ]]; then
51-
figlet_output=$(figlet -f slant "$app_name" 2>/dev/null || echo "FIGLET ERROR: $app_name")
52-
echo "### $(basename "$script")" >> "$output_file"
53-
echo "APP=$app_name" >> "$output_file"
54-
echo "$figlet_output" >> "$output_file"
55-
echo >> "$output_file"
56-
fi
57-
done
47+
git add ./misc/.app-headers
48+
git commit -m "Update .app-headers file"
49+
git push origin "$BRANCH_NAME"
5850
59-
# Step 6: Commit and push changes
60-
- name: Commit and push changes
51+
# Step 6: Delete the created branch locally and remotely after push
52+
- name: Delete the branch after push
6153
run: |
62-
git add ct/.app-headers
63-
git commit -m "Update .app-headers on $(date +"%Y-%m-%d")" || echo "No changes to commit"
64-
git push --force origin update-app-headers
54+
git push origin --delete "$BRANCH_NAME" # Delete remote branch
55+
git checkout main
56+
git branch -D "$BRANCH_NAME" # Delete local branch
57+
echo "Branch $BRANCH_NAME deleted."

0 commit comments

Comments
 (0)