Skip to content

Auto PR for Site Package Changes #5

Auto PR for Site Package Changes

Auto PR for Site Package Changes #5

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
shell: bash
- name: Run Generate Site Package Script
run: |
chmod +x Build/DownloadSitePackage/generate_sitepackage.sh
./Build/DownloadSitePackage/generate_sitepackage.sh
- name: Check for Changes
run: |
if git diff --quiet; then
echo "No changes detected, skipping PR creation."
exit 0
fi
- name: Create a New Branch for Changes
run: |
git checkout -b ${{ env.NEW_BRANCH }}
git add .
git commit -m "${{ env.COMMIT_MESSAGE }}"
- name: Push Changes to New Branch
run: |
git push --set-upstream origin ${{ env.NEW_BRANCH }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.NEW_BRANCH }} # Source branch (newly created branch)
base: ${{ env.BASE_BRANCH }} # Target branch (main or production branch)
title: ${{ env.PR_TITLE }}
body: ${{ env.PR_BODY }}