Auto PR for Site Package Changes #13
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 1 * *' # Run at 2:00 AM UTC on the 1st day of every month | |
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@v4 | |
with: | |
ref: 'main' | |
- 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: 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: | | |
# git checkout -b ${{ env.NEW_BRANCH }} | |
chmod +x Build/DownloadSitePackage/generate_sitepackage.sh | |
./Build/DownloadSitePackage/generate_sitepackage.sh | |
git diff --exit-code || echo "FIX_NEEDED=true" >> $GITHUB_ENV | |
- name: Commit and push to new Branch for Changes | |
if: env.FIX_NEEDED == 'true' | |
run: | | |
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 }}" | |
# echo "Pushing to remote branch: ${{ env.NEW_BRANCH }}" | |
# git push --set-upstream origin ${{ env.NEW_BRANCH }} | |
- name: Create Pull Request | |
if: env.FIX_NEEDED == 'true' | |
uses: peter-evans/create-pull-request@v7 | |
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 }} |