Coder Social home page Coder Social logo

action-rollback's Introduction

author/action-rollback

This action will rollback/delete a Github release. It is designed as a failsafe for workflows that do not complete, produce errors, fail to publish, or any other circumstance where removing a release is applicable.

For example, consider the lifecycle of a Javascript package being published to npm.

test-->build-->tag-->release-->publish

In the scenario where publishing fails, it may be desirable to rollback the release.

Workflow

The following is an example .github/publish.yml that will rollback a release when a publish fails.

Configuring the action is straightforward:

- name: Rollback Release
  if: failure()
  uses: author/action-rollback@stable
  with:
    # Using a known release ID
    id: ${{ steps.create_release.id }}
    # Using a tag name
    tag: 'v1.0.1'
    # Always delete the tag, even if a release is not associated with it.
    always_delete_tag: true
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

It's a bit easier to understand in context of a complete workflow:

name: Publish

on:
  push:
    branches:
      - master

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Tag
        id: autotagger
        uses: butlerlogic/action-autotag@stable
        with:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      
      - name: Release
        id: create_release
        if: steps.autotagger.outputs.tagname != ''
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.autotagger.outputs.tagname }}
          release_name: Version ${{ steps.autotagger.outputs.version }}
          body: ${{ steps.autotagger.outputs.tagmessage }}
          draft: false
          prerelease: true

      - name: Publish
        id: publish_npm
        if: steps.autotagger.outputs.tagname != ''
        uses: author/action-publish@stable
        env:
          REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}

      - name: Rollback Release
        if: failure() && steps.create_release.outputs.id != ''
        uses: author/action-rollback@stable
        with:
          # Using a known release ID
          id: ${{ steps.create_release.id }}
          # Using a tag name
          tag: ${{ steps.autotagger.outputs.tagname }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Only the id or tag need to be specified. If a publish fails, the release will be removed.

What is the purpose of delete_orphan_tag?

It's a way to clean up messy processes.

It may seem unnecessary at first. However; it is useful when a release is removed through other means, leaving an orphan tag.

Technically, this attribute could be used if you only need to rollback tags of any kind (regardless of whether a release exists).


Credits

This action was written and is primarily maintained by Corey Butler.

Our Ask...

If you use this or find value in it, please consider contributing in one or more of the following ways:

  1. Click the "Sponsor" button at the top of the page.
  2. Star it!
  3. Tweet about it!
  4. Fix an issue.
  5. Add a feature (post a proposal in an issue first!).

Copyright © 2020 Author.io, Corey Butler, and Contributors.

action-rollback's People

Contributors

coreybutler avatar ssmirr avatar

Watchers

 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.