Skip to content

Latest commit

 

History

History
149 lines (114 loc) · 5.08 KB

README.md

File metadata and controls

149 lines (114 loc) · 5.08 KB

update_release (GitHub Release API)

Release Version Actions Status Coverage Status license standard-readme compliant PRs Welcome

This GitHub Action (written in JavaScript) is to change the Body Text and Name of an already created Release with using the GitHub Release API.

Table of Contents

Install

Pre-requisites

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.

Usage

Inputs

Change GitHub Releases, if you set the inputs.

  • release_name
    • If this item is set, the release name is overridden.
  • body
    • If this item is set, the body text is overridden.
  • draft
    • If this item is set, the draft is overridden.
  • prerelease
    • If this item is set, the prerelease is overridden.
  • is_append_body
    • If true, append body text on old one.
  • body_path
    • Path to file with new body text.

Outputs

Environment variables

  • GITHUB_TOKEN
    • The github auth token (mandatory)
  • TAG_NAME
    • The name of the tag a release is searched for. If not set context.ref will be used instead.

Example workflow - update a release

name: Release

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            asset_name_suffix: ''
            asset_content_type: application/octet-stream
          - os: windows-latest
            asset_name_suffix: .exe
            asset_content_type: application/octet-stream
          - os: macOS-latest
            asset_name_suffix: ''
            asset_content_type: application/octet-stream
    steps:
      - uses: actions/checkout@v1
      - uses: tubone24/setup-nim-action@v1.0.1
      - name: Install Dependencies
        run: nimble install -d --accept
      - name: Build
        run: nimble build -d:release
      - name: get version
        id: get_version
        run: |
          echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
      - name: update release
        id: update_release
        uses: tubone24/update_release@v1.0
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          body: test_body # new body text
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.github_token }}
        with:
          upload_url: ${{ steps.update_release.outputs.upload_url }}
          asset_path: ./bin/post_twitter_on_work${{ matrix.asset_name_suffix }}
          asset_name: post_twitter_on_work_${{ runner.os }}_${{ steps.get_version.outputs.VERSION }}${{ matrix.asset_name_suffix }}
          asset_content_type: ${{ matrix.asset_content_type }}

on-release-created is a event to create a release and you can get release id on the actions. Also changed body text.

This uses the GITHUB_TOKEN provided by the virtual environment, so no new token is needed.

Demos

See the repo:

https://github.com/tubone24/post_twitter_on_work

Test

If you modify this codes, run unit test with jest.

npm test

Also, this repo is integrated with GitHub Action.

So, Run CI test, if you write test.

Contributing

See the contributing file!

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © tubone.