Auto PR for Site Package Changes #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto PR for Site Package Changes | |
on: | |
schedule: | |
- cron: '0 2 * * *' # Run daily at 2:00 AM UTC | |
workflow_dispatch: # Manual trigger | |
jobs: | |
auto-pr: | |
name: Create PR for Site Package Changes | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMIT_MESSAGE: 'Auto-update of site package files' | |
PR_TITLE: 'Automated Update of Site Package Files' | |
PR_BODY: 'This PR contains automatic updates to the site package files generated by the script.' | |
BASE_BRANCH: 'main' # The branch you want to merge the PR into | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set Up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Check out the base branch (main) | |
run: | | |
git fetch origin ${{ env.BASE_BRANCH }} | |
git checkout ${{ env.BASE_BRANCH }} | |
- name: Generate Unique Branch Name | |
run: | | |
NEW_BRANCH="auto/sitepackage-update-$(date +%s)" | |
echo "NEW_BRANCH=$NEW_BRANCH" >> $GITHUB_ENV | |
echo "New branch name: $NEW_BRANCH" | |
shell: bash | |
- name: Run Generate Site Package Script | |
run: | | |
chmod +x Build/DownloadSitePackage/generate_sitepackage.sh | |
./Build/DownloadSitePackage/generate_sitepackage.sh | |
- name: Debug Changes Before Commit | |
run: | | |
git status --short | |
git diff | |
- name: Create a New Branch for Changes | |
run: | | |
git checkout -b ${{ env.NEW_BRANCH }} | |
git add --all # Stage all changes | |
git status --short # Verify that files are staged properly | |
git diff --cached # Show the changes that will be committed | |
git commit -m "${{ env.COMMIT_MESSAGE }}" | |
- name: Push Changes to New Branch | |
run: | | |
echo "Pushing to remote branch: ${{ env.NEW_BRANCH }}" | |
git push --set-upstream origin ${{ env.NEW_BRANCH }} | |
- name: Verify Branch | |
run: | | |
git branch -r | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
source-branch: ${{ env.NEW_BRANCH }} # Source branch (newly created branch) | |
target-branch: ${{ env.BASE_BRANCH }} # Target branch (main or production branch) | |
title: ${{ env.PR_TITLE }} | |
body: ${{ env.PR_BODY }} |