Skip to content

Commit

Permalink
Update generate-app-headers.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
MickLesk authored Jan 10, 2025
1 parent f275cdd commit 7a2f5f5
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions .github/workflows/generate-app-headers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,64 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure we have full access to all branches
fetch-depth: 0 # Fetch all branches for full context

# Step 2: Check or Create update-app-headers branch
- name: Check or Create update-app-headers branch
# Step 2: Set up Git user
- name: Configure Git user
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# Step 3: Check or create update-app-headers branch
- name: Check or create update-app-headers branch
run: |
git fetch origin
if ! git show-ref --quiet refs/heads/update-app-headers; then
echo "Creating 'update-app-headers' branch."
git checkout -b update-app-headers origin/main
else
if git show-ref --quiet refs/heads/update-app-headers; then
echo "Switching to 'update-app-headers' branch."
git checkout update-app-headers
else
echo "Creating 'update-app-headers' branch."
git checkout -b update-app-headers origin/main
fi
# Step 3: Ensure .app-headers file exists and verify content
- name: Ensure .app-headers file exists and verify content
# Step 4: Merge main into update-app-headers
- name: Merge main into update-app-headers
run: |
git merge origin/main --no-edit || echo "No changes to merge from main."
# Step 5: Ensure .app-headers file exists
- name: Ensure .app-headers file exists
run: |
if [ ! -f ".app-headers" ]; then
echo "The .app-headers file does not exist. Creating it."
echo "Generated by CI" > .app-headers
echo "Creating .app-headers file."
echo "Generated by CI on $(date)" > .app-headers
else
echo ".app-headers already exists."
echo ".app-headers file already exists."
fi
# Step 4: Commit and push changes (if any)
- name: Commit and push changes (if any)
# Step 6: Commit and push changes (if any)
- name: Commit and push changes
run: |
git diff --quiet -- .app-headers || git commit -am "[core]: update .app-headers to latest version"
git push origin update-app-headers --force
# Step 5: Create Pull Request if changes detected
# Step 7: Create Pull Request if changes detected
- name: Create Pull Request if changes detected
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" | grep -o '[0-9]\+')
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 -q .url)
echo "PR created: $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
else
echo "PR already exists."
fi
# Step 6: Automatically merge PR
# Step 8: Automatically merge PR
- name: Automatically merge PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -78,7 +88,7 @@ jobs:
echo "No PR found to merge."
fi
# Step 7: Final status output
# Step 9: Final status output
- name: Output final status
run: |
echo "Workflow completed successfully. Branch and PR status updated."

0 comments on commit 7a2f5f5

Please sign in to comment.