GithubHelp home page GithubHelp logo

gha-utilities_workspace-commit's Introduction

GHA Workspace Commit

JavaScript wrapper runs child_process.execSync("git commit ...") on GitHub Actions

Byte size of workspace-commit Open Issues Open Pull Requests Latest commits


Table of Contents


Requirements

Access to GitHub Actions if using on GitHub, or manually assigning environment variables prior to running npm test.


Quick Start

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.

Notes

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

Attribution


License

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/>.

gha-utilities_workspace-commit's People

Contributors

s0ands0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.