From 89fb2831c69ca3150f1134aa649fc47012bef803 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 3 May 2024 19:06:49 -0400 Subject: [PATCH] add create github commit action --- github/commit/create/action.yaml | 51 +++++++++++++++++++ .../commit/create/commit_and_push_changes.sh | 7 +++ 2 files changed, 58 insertions(+) create mode 100644 github/commit/create/action.yaml create mode 100644 github/commit/create/commit_and_push_changes.sh diff --git a/github/commit/create/action.yaml b/github/commit/create/action.yaml new file mode 100644 index 00000000..c8a8ea65 --- /dev/null +++ b/github/commit/create/action.yaml @@ -0,0 +1,51 @@ +name: "Create GitHub commit" +description: "Commit changes into the current branch, push back to the remote, and return the resulting SHA" + +inputs: + message: + description: "The commit message" + required: true + user: + description: "The user for the commit" + default: "Github Build Bot" + email: + description: "The email for the commit" + default: "buildbot@fishtownanalytics.com" + +outputs: + sha: + description: "The SHA for the commit" + value: ${{ steps.commit.outputs.sha }} + +runs: + using: composite + steps: + - name: "[DEBUG] Inputs" + shell: bash + run: | + echo "==========INPUTS==========" + echo message : ${{ inputs.message }} + echo user : ${{ inputs.user }} + echo email : ${{ inputs.email }} + + - name: "Commit and push changes" + id: commit + shell: bash + run: ./github/commit/create/commit_and_push_changes.sh + env: + USER: ${{ inputs.user }} + EMAIL: ${{ inputs.email }} + MESSAGE: "[automated] ${{ inputs.message }}" + + - name: "[INFO] Create GitHub commit" + shell: bash + run: echo "::notice title=$TITLE::$MESSAGE" + env: + TITLE: "[${{ env.NOTIFICATION_PREFIX }}] Create GitHub commit" + MESSAGE: "Committed and pushed changes back to the remote repository with SHA `${{ steps.commit.outputs.sha }}`" + + - name: "[DEBUG] Outputs" + shell: bash + run: | + echo "==========OUTPUTS==========" + echo sha : ${{ steps.commit.outputs.sha }} diff --git a/github/commit/create/commit_and_push_changes.sh b/github/commit/create/commit_and_push_changes.sh new file mode 100644 index 00000000..d139c600 --- /dev/null +++ b/github/commit/create/commit_and_push_changes.sh @@ -0,0 +1,7 @@ +git config user.name "$USER" +git config user.email "$EMAIL" +git pull +git add . +git commit -m "$MESSAGE" +git push +echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT