Skip to content

Commit

Permalink
chore: Add workflow actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 26, 2023
1 parent a4de3db commit 8cc1841
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/github-app-token/action.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
62 changes: 62 additions & 0 deletions .github/actions/pr/action.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8cc1841

Please sign in to comment.