Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.03 KB

README.md

File metadata and controls

64 lines (48 loc) · 2.03 KB

GitHub Action - Write Version To File

This GitHub action writes the version information from a given variable into a file with a well known JSON structure. Once the file is written it will perform a commit to the repository with the changed version file.

Github JavaScript Actions CI/CD

Pre requisites

node <= 12 yarn git

Usage

Create a workflow .yml file in your .github/workflows directory. An example workflow is available below.

For more information, reference the GitHub Help Documentation for Creating a workflow file

Inputs

  • version: The version number to use.
  • path: The path to the file within the repository.
  • user-email: The email of the user that commits the version file.
  • user-name: The name of the user that commits the version file.
  • merge-strategy: How to reconcile divergent branches when pulling.
    • merge: Tries to merge (default)
    • rebase: Tries to rebase
    • fast-forward: Only allows for fast forwards

For information on how GitHub actions tokens work, read more here.

Example Workflow

on:
  push:
    branches:
    - '**'
  pull_request:
    types: [closed]

name: GitHub action workflow name

jobs:
  context:
    name: Job name
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Get current version
        uses: dolittle/write-version-to-file-action@v2
        with:
          version: ${{ steps.context.outputs.current-version }}
          path: ./Source/version.json
          user-email: [email protected]
          user-name: dolittle-build
          merge-strategy: merge

Contributing

We're always open for contributions and bug fixes!