JavaScript wrapper runs child_process.execSync("git commit ...")
on GitHub Actions
Access to GitHub Actions if using on GitHub, or manually assigning environment variables prior to running npm test
.
Reference the code of this repository within your own workflow
...
on:
push:
branches:
- src-pages
jobs:
jekyll_build:
runs-on: ubuntu-latest
steps:
- name: Checkout source branch for building Pages
uses: actions/checkout@v1
with:
ref: src-pages
fetch-depth: 10
- name: Make build destination directory
run: mkdir -vp ~/www/repository-name
- name: Jekyll Build
uses: gha-utilities/[email protected]
with:
jekyll_github_token: ${{ secrets.JEKYLL_GITHUB_TOKEN }}
source: ./
destination: ~/www/repository-name
- name: Checkout branch for Pull Requesting to GitHub Pages
uses: actions/checkout@v1
with:
ref: pr-pages
fetch-depth: 1
submodules: true
- name: Copy built site files into Git branch
run: cp -r ~/www/repository-name ./
- name: Add changes to Git tracking
run: git add -A .
- name: Commit changes
with: gha-utilities/[email protected]
author: ${{ github.author }}
email: [email protected]
message: Updates compiled site files
all: true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: pr-pages
- name: Initialize Pull Request
uses: gha-utilities/[email protected]
with:
pull_request_token: ${{ secrets.GITHUB_TOKEN }}
head: pr-pages
base: gh-pages
title: 'Updates site files from latest Actions build'
body: >
Perhaps a multi-line description
about latest features and such.
This Action is intended for committing local Workspace repository changes, and does not assume that an immediate push is wanted; Pull Requests are certainly welcomed if bugs are found, or more commit related Inputs translation are desired.
The commit author defaults to user name of gha-utilities
and email of [email protected]
, may be modified within your Workflows as well as selecting a subset of staged paths to commit...
- name: Workspace Commit
uses: gha-utilities/[email protected]
with:
paths: |
README.md
index.js
etc
message: Updates compiled site files
author: ${{ github.author }}
email: [email protected]
... At which point running git commit
directly from a Workflow without this action may be shorter for one-line commit messages...
- name: Commit Changes
run: |
git -c "user.name ${{ github.actor }}"\
-c "user.email [email protected]"\
README.md\
index.js\
etc\
commit "_message_"
If user.name
and/or user.email
are assigned prior to running gha-utilities/workspace-commit
, then it should still be possible to temporarily overwrite either for an individual commit...
- name: Configure Git user.name
run: git config user.name Your_GitHub_Name
- name: Configure Git user.email
run: git config user.email Your_GitHub_Email
# ...
- name: Commit changes
with: gha-utilities/[email protected]
author: ${{ github.author }}
email: [email protected]
message: Updates compiled site files
all: true
... In such cases the user.name
and/or user.email
configurations will be reverted values set prior to commit action.
Notice in cases where the user.name
and/or user.email
configurations where not set prior to running the gha-utilities/workspace-commit
action, then configurations will persist!
Multi-line commit messages are possible from Workflow file(s), and should also allow for environment variables...
- name: Workspace Commit
uses: gha-utilities/[email protected]
env:
COMMIT_MESSAGE_FOOTER: This commit was applied automatically from an Action
with:
all: true
message: >
Updates compiled site files
${COMMIT_MESSAGE_FOOTER}
Local testing of this Action is possible by defining environment variables...
GITHUB_ACTOR='User_Name'\
GITHUB_REPOSITORY='organization/repository'\
INPUT_AUTHOR='Git_Name'\
INPUT_EMAIL='[email protected]'\
INPUT_MESSAGE='test workspace-commit index.js'\
INPUT_PATHS='file.ext'\
node ~/git/hub/gha-utilities/workspace-commit/index.js
-
GitHub -- Creating a JavaScript Action, specifically the
commit-and-push-your-action-to-github
section that states dependencies must be checked into Git tracking. -
StackOverflow -- GitHub Actions share Workspace Artifacts between jobs
Legal bits of Open Source software. Note the following license does not necessarily apply to any dependencies of this repository.
Workspace Commit GitHub Actions documentation
Copyright (C) 2019 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.