|
| 1 | +--- |
| 2 | +name: Auto Generated PR From Main to Staging |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-commit: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + name: Check For a Commit |
| 11 | + outputs: |
| 12 | + should_run: ${{ steps.should_run.outputs.should_run }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + - name: Print Latest Commit |
| 16 | + run: echo ${{ github.sha }} |
| 17 | + |
| 18 | + - name: Check if There Has Been A Commit |
| 19 | + id: should_run |
| 20 | + continue-on-error: false |
| 21 | + run: | |
| 22 | + sha=$(git rev-list --after="24 hours" ${{ github.sha }}) |
| 23 | + if test -z $sha |
| 24 | + then |
| 25 | + echo "should_run=false" >> $GITHUB_OUTPUT |
| 26 | + else |
| 27 | + echo "should_run=true" >> $GITHUB_OUTPUT |
| 28 | + fi |
| 29 | +
|
| 30 | + pull-request: |
| 31 | + name: Create Pull Request |
| 32 | + needs: [check-commit] |
| 33 | + if: ${{ needs.check-commit.outputs.should_run != 'false' }} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + outputs: |
| 36 | + pr_number: ${{ steps.open-pr.outputs.pr_number }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + - name: Get Current Date |
| 40 | + id: date |
| 41 | + run: | |
| 42 | + echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + - name: Get Git Short Commit |
| 45 | + id: git-short |
| 46 | + run: | |
| 47 | + echo "short_sha=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Open Pull Request |
| 50 | + uses: repo-sync/pull-request@v2 |
| 51 | + id: open-pr |
| 52 | + with: |
| 53 | + source_branch: "main" |
| 54 | + destination_branch: "prod" |
| 55 | + pr_title: "${{ steps.date.outputs.date }} ${{ steps.git-short.outputs.short_sha }} main -> prod" |
| 56 | + pr_label: "autogenerated" |
| 57 | + pr_body: | |
| 58 | + This is an auto-generated PR to merge main into prod for a staging release for ${{ steps.date.outputs.date }} |
| 59 | + Last commit being merged: ${{ steps.git-short.outputs.short_sha }} |
| 60 | + pr_reviewer: "fac-admins" |
| 61 | + pr_allow_empty: false |
| 62 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments