GithubHelp home page GithubHelp logo

isabella232 / step-github-upload-asset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xchapter7x/step-github-upload-asset

0.0 0.0 0.0 1.53 MB

A wercker step for adding an asset to a GitHub release.

License: MIT License

Shell 100.00%

step-github-upload-asset's Introduction

GitHub upload asset step

A wercker step for adding an asset to a GitHub release. It has a few parameters, but only two are required: token and file. See Creating a GitHub token.

This step will export the id of the asset in an environment variable (default: $WERCKER_GITHUB_UPLOAD_ASSET_ID). This allows other steps to use this release.

Currently this step does not do any json escaping. So be careful when using quotes or newlines in parameters.

More information about GitHub releases:

Example

A minimal example, this will get the token from a environment variable, upload a file which is located in the current working directory called build.tgz and add it to release 1:

deploy:
    steps:
        - github-upload-asset:
            token: $GITHUB_TOKEN
            file: build.tgz
            release_id: 1

This step works best when used together with the github-create-release step, because you can skip setting the release_id:

deploy:
    steps:
        - github-create-release:
            token: $GITHUB_TOKEN
            tag: v1.0.0
        - github-upload-asset:
            token: $GITHUB_TOKEN
            file: build.tgz

Common problems

file: command not found

This happens when the file command cannot be found. We use the file command to figure out the content-type of the file that will be uploaded. Either you install file on your container, or you specify content-type by using the content-type property (see Options).

curl: (22) The requested URL returned error: 400

GitHub has rejected the call. Most likely invalid json was used. Check to see if any of the parameters need escaping (quotes and new lines).

curl: (22) The requested URL returned error: 401

The token is not valid. If using a protected environment variable, check if the token is inside the environment variable.

curl: (22) The requested URL returned error: 422

GitHub rejected the API call. Check if the name of the file isn't already in use in this release.

Creating a GitHub token

To be able to use this step, you will first need to create a GitHub token with an account which has enough permissions to be able to create releases. First goto Account settings, then goto Applications for the user. Here you can create a token in the Personal access tokens section. For a private repository you will need the repo scope and for a public repository you will need the public_repo scope. Then it is recommended to save this token on wercker as a protected environment variable.

What's new

  • Initial release.

Options

  • token The token used to make the requests to GitHub. See Creating a GitHub token.
  • file The path of the file which you want to add to the release.
  • release_id (optional) The id of a release where this asset should be uploaded to. Defaults to $WERCKER_GITHUB_CREATE_RELEASE_ID, which gets set by the github-create-release step.
  • owner (optional) The GitHub owner of the repository. Defaults to $WERCKER_GIT_OWNER, which is the GitHub owner of the original build.
  • repo (optional) The name of the GitHub repository. Defaults to $WERCKER_GIT_REPOSITORY, which is the repository of the original build.
  • filename (optional) The name of the file on GitHub (make sure this is json encoded, see TODO)
  • content-type (optional) The content-type of the file. Defaults to using the file command (make sure this is json encoded, see TODO)
  • export_id (optional) After the asset is uploaded, a asset id will be made available in the environment variable identifier in this environment variable. Defaults to WERCKER_GITHUB_UPLOAD_ASSET_ID.

TODO

  • Create better error handling for invalid token.
  • Escape user input to be valid json.
  • Make sure export_id contains a valid environment variable identifier.

License

The MIT License (MIT)

Changelog

2.0.0

  • Update jq from 1.3 to 1.5

1.0.1

  • Initial release.

step-github-upload-asset's People

Contributors

gilbode avatar hatchan 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.