diff --git a/.github/actions/github-app-token/action.yaml b/.github/actions/github-app-token/action.yaml new file mode 100644 index 000000000..e3d21b1aa --- /dev/null +++ b/.github/actions/github-app-token/action.yaml @@ -0,0 +1,24 @@ +name: github_app_token +description: Create a token for making Pull Requests + +# Note: this just calls tibdex/github-app-token, but it allows us to keep it in one place. + +inputs: + app_id: + description: Application ID used to make the PR + required: true + app_private_key: + description: Application Private Key used to sign the PR + required: true +outputs: + token: + description: A token for making Pull Requests + value: ${{ steps.generate-token.outputs.token }} +runs: + using: "composite" + steps: + - uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c # v1.5 # cspell:ignore tibdex + id: generate-token + with: + app_id: ${{ inputs.app_id }} + private_key: ${{ inputs.app_private_key }} diff --git a/.github/actions/pr/action.yaml b/.github/actions/pr/action.yaml new file mode 100644 index 000000000..63849d7c8 --- /dev/null +++ b/.github/actions/pr/action.yaml @@ -0,0 +1,62 @@ +name: create_pr +description: Create A Pull Request That will Trigger Workflows +inputs: + base: + description: The Base Ref to apply the diff + required: false + body: + description: Optional body of the PR + required: false + commit-message: + description: Commit Message for the PR + required: true + branch: + description: The Branch to create for the PR + required: true + title: + description: PR title - defaults to commit-message + required: false + app_id: + description: Application ID used to make the PR + required: true + app_private_key: + description: Application Private Key used to sign the PR + required: true +runs: + using: "composite" + steps: + - name: Has changes + shell: bash + run: | + git --no-pager diff --compact-summary --exit-code && echo "git_status=clean" >> $GITHUB_ENV || echo "git_status=dirty" >> $GITHUB_ENV + git --no-pager diff --compact-summary + + - name: Echo git_status + shell: bash + run: echo "${{ env.git_status }}" + + - name: Body + shell: bash + env: + git_body: ${{ inputs.body }} + run: | + echo "$git_body" + + - uses: ./.github/actions/github-app-token + if: env.git_status == 'dirty' + id: generate-token + with: + app_id: ${{ inputs.app_id }} + app_private_key: ${{ inputs.app_private_key }} + + - name: Create Pull Request + if: env.git_status == 'dirty' + uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4 + with: + commit-message: ${{ inputs.commit-message }} + branch: ${{ inputs.branch }} + base: ${{ inputs.base }} + title: ${{ inputs.title || inputs.commit-message }} + token: ${{ steps.generate-token.outputs.token }} + body: ${{ inputs.body }} + delete-branch: true