Nightly Build #46
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: Nightly Build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 12 * * * # Runs at 12:00 UTC every day | |
jobs: | |
check-and-create-pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Fetch develop branch | |
run: git fetch origin develop | |
- name: Check if main and develop are in sync | |
id: check_sync | |
run: | | |
MAIN_HASH=$(git rev-parse origin/main) | |
DEVELOP_HASH=$(git rev-parse origin/develop) | |
echo "Main branch commit hash: $MAIN_HASH" | |
echo "Develop branch commit hash: $DEVELOP_HASH" | |
if [ "$MAIN_HASH" != "$DEVELOP_HASH" ]; then | |
echo "out_of_sync=true" >> $GITHUB_OUTPUT | |
else | |
echo "out_of_sync=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Check if pull request already exists from develop to main | |
id: check_pr | |
uses: juliangruber/find-pull-request-action@v1 | |
with: | |
branch: develop | |
base: main | |
- name: Create pull request from develop to main if out of sync and no PR exists | |
if: steps.check_sync.outputs.out_of_sync == 'true' && steps.check_pr.outputs.number == '' | |
run: | |
gh pr create -B main -H develop --title 'Merge develop into main' --body 'Created by Github action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |