|
6 | 6 | - main |
7 | 7 | paths: |
8 | 8 | - 'ct/**.sh' |
9 | | - workflow_dispatch: |
| 9 | + workflow_dispatch: # Ermöglicht das manuelle Ausführen der Action |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - auto-update: |
| 12 | + update-app-headers: |
13 | 13 | runs-on: ubuntu-latest |
| 14 | + |
14 | 15 | steps: |
15 | | - # Step 1: Checkout repository |
| 16 | + # Step 1: Checkout the repository |
16 | 17 | - name: Checkout repository |
17 | 18 | uses: actions/checkout@v2 |
18 | 19 |
|
19 | | - # Step 2: Set up Git user |
| 20 | + # Step 2: Set up Git user for committing changes |
20 | 21 | - name: Set up Git |
21 | 22 | run: | |
22 | 23 | git config --global user.name "GitHub Actions" |
23 | 24 | git config --global user.email "[email protected]" |
24 | 25 |
|
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 |
27 | 28 | 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 |
33 | 38 | 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 }} |
35 | 43 |
|
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 |
38 | 46 | 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" |
58 | 50 |
|
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 |
61 | 53 | 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