Update generate-app-headers.yaml

This commit is contained in:
CanbiZ 2025-01-10 13:09:46 +01:00 committed by GitHub
parent 7930764ece
commit 2dddbaebe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,33 +31,27 @@ jobs:
git checkout update-app-headers
fi
# Step 3: Ensure .app-headers file exists
- name: Ensure .app-headers file exists
# Step 3: Ensure .app-headers file exists and verify content
- name: Ensure .app-headers file exists and verify content
run: |
if [ ! -f ".app-headers" ]; then
echo "The .app-headers file does not exist. Creating it."
echo "Generated by CI" > .app-headers
else
echo ".app-headers already exists."
echo ".app-headers already exists. Checking if there are any changes."
fi
# Step 4: Check for changes in the .app-headers file content
- name: Check if .app-headers has changes
id: check_changes
run: |
git diff --quiet origin/main..HEAD -- .app-headers
echo "Changes detected: $?"
continue-on-error: true # So the workflow continues even if no changes are detected
# Verifying if there are changes in .app-headers file content
git diff --quiet -- .app-headers || echo "Changes detected in .app-headers"
# Step 5: Commit changes if detected
# Step 4: Commit changes if detected
- name: Commit changes if detected
if: steps.check_changes.outcome == 'failure'
if: ${{ steps.verify_changes.outputs.changes_detected == 'true' }}
run: |
echo "Changes detected in .app-headers. Committing changes."
git commit -am "[core]: update .app-headers to latest version"
git push origin update-app-headers --force
# Step 6: Create Pull Request if changes detected
# Step 5: Create Pull Request if changes detected
- name: Create Pull Request if changes detected
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -65,14 +59,30 @@ jobs:
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then
echo "Creating a new PR."
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
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 --json url -q .url)
echo "PR created: $PR_URL"
else
echo "PR already exists."
fi
# Step 6: Automatically merge the PR if no conflicts
- name: Automatically merge PR
if: ${{ steps.verify_changes.outputs.changes_detected == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempting to merge PR."
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge "$PR_NUMBER" --merge --admin --delete-branch
echo "PR merged successfully."
else
echo "No PR found to merge."
fi
# Step 7: Final status output
- name: Output final status
run: |