Pull Request Factory #481
This file contains hidden or 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: Pull Request Factory | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: "*/30 * * * *" | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| merge-pr: | |
| if: github.repository == 'trunk-io/flake-farm-staging-fork-prs' | |
| runs-on: [ubuntu-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: trunk install | |
| uses: trunk-io/trunk-action/install@v1 | |
| with: | |
| tools: gh | |
| - name: Merge active change | |
| env: | |
| GH_TOKEN: ${{ secrets.FARM_PAT }} | |
| id: merge | |
| run: javascript/src/season/merge_next | |
| create-pr: | |
| if: github.repository == 'trunk-io/flake-farm-staging-fork-prs' | |
| needs: merge-pr | |
| runs-on: [ubuntu-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: run switch season | |
| id: switch | |
| run: javascript/src/season/flip | |
| - name: Get current date | |
| id: date | |
| run: | | |
| echo "month=$(date +'%B')" >> $GITHUB_OUTPUT | |
| echo "day=$(date +'%d')" >> $GITHUB_OUTPUT | |
| - name: choose next | |
| id: choose-next | |
| run: | | |
| if [[ "${{ steps.switch.outputs.season }}" == "Duck" ]]; then | |
| echo "title=Duck 🦆" >> $GITHUB_OUTPUT | |
| else | |
| echo "title=Rabbit 🐇" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.FARM_PAT_PR_OPENER }} | |
| branch-token: ${{ secrets.FARM_PAT_FORK }} | |
| push-to-fork: trunk-io/flake-farm-staging-fork-prs-generator | |
| # Necessary for fork perms restrictions and the isolation of our tokens | |
| maintainer-can-modify: false | |
| commit-message: Everyone knows its ${{ steps.switch.outputs.season }} | |
| title: ${{ steps.choose-next.outputs.title }} season | |
| body: ${{ steps.date.outputs.month }} ${{ steps.date.outputs.day }} is ${{ steps.switch.outputs.season }} season | |
| labels: ${{ steps.switch.outputs.season }} | |
| branch: ${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}/season |