Giter VIP home page Giter VIP logo

git-notes-action's Introduction

Add, override and output git notes

Action allowing to manipulate git notes in several stages of your pipeline.

"A typical use of notes is to supplement a commit message without changing the commit itself."

man 1 git-notes

One use case example is, which made me create this, was that I needed to pass on a single string from one workflow A to another workflow B, B was triggered on A's completion. It seemed too overkill to upload an artifact to do it so, and the information being passed on was contextual to the commit, so here we are.

This is the only use case for now.

Only tested on linux & mac.

If you are Adding / Overriding notes and not only reading, you need to clone your repository with a PAT(Personal Access Token).

Usage

- id: example-run
  name: Notes Action
  uses: marcoslopes/git-notes-action
  with:
    # Required, which object to attach note to
    sha: ${{ github.sha }}
    # Optional, Notes message, if present will Add / Override*
    message: "optional message"
    # Optional, Remote to fetch / push notes to
    remote: "origin"
    # Optional, repository path, defaults to current directory
    path: "."
    # Optional, notes ref
    ref: "commits"
    # Optional, override note with current 'message' if true
    override: false
    # Optional, git config user.name
    name: "Git Notes Action"
    # Optional, git config user.email
    email: "[email protected]"

Examples

writing value

...

- name: checkout source
  uses: actions/checkout@v2
  with:
    fetch-depth: 1
    token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- id: save-value
  uses: marcoslopes/git-notes-action@v1
  with:
    sha: ${{ github.sha }}
    ref: 'some-other-scope'
    message: "${{ steps.some-previous-step.outputs.some-value }}"
# download all notes refs
git fetch origin "refs/notes/*:refs/notes/*" -f

# show notes from all refs
git log --show-notes="*"

# show notes from some-other-scope ref
git log --show-notes="some-other-scope"

...

commit 0000000000000000000000000000000000000000 (HEAD -> main, origin/main)
Author: Marcos Antonio Lopes <[email protected]>
Date:   Sun Oct 00 00:00:00 2021 +1300

    test notes commit

Notes (some-other-scope):
    some-value-from-some-previous-step-output

...

reading value

...

- id: get-value
  uses: marcoslopes/git-notes-action@v1
  with:
      sha: ${{ github.sha }}
      ref: 'some-other-scope'
  
- id: use-value
  run: |
      echo "value from note ${{ steps.get-value.outputs.message }}"

...

git-notes-action's People

Contributors

marcoslopes avatar stokesbga avatar

Watchers

James Cloos 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.