Code Monkey home page Code Monkey logo

github-artifact-download's Introduction

GitHub Action Artifact Downloader

GitHub does currently not provide an easy way to download an artifact from the lastest successful GitHub Action build. This tool is meant to fill that gap.

Requirements

Python 3.4+, no other dependencies

Installation

Simply clone this repository and call the github-artifact-download.py

Usage Guide

GitHub currently restricts download of artifacts to authenticated users. That means that you need to create a Personal Access Token to use this tool. The token can either be supplied via an environment variable GITHUB_TOKEN, or using the --token argument. For public repositories, only the "public_repo" scope is required for this access token.

Only a single asset can be downloaded in one invokation of the tool. There are two modes of operation:

  1. Find the latest artifact by name in all artifacts of the repository,
  2. Find the latest successful run of a particular workflow and download a named artifact from that run.

After an artifact has been downloaded, it's full path on the local filesystem is printed to stdout. This is designed to help in additional (shell) scripts that further process the downloaded file.

To prevent re-downloading the same file again, you can specify a --cache-file filepath to which the asset id of the last downloaded file will be written. If the found asset matches the id in that file, it is skipped and the skript exists without outputting the filename.

Usage Examples

Note: in the following examples, owner/repo is a placeholder for your target repositories owner and name. So to download artifacts from this repository for example, you would use mawe42/github-artifact-download (don't do this, there are not Actions set up here :-).

All examples below assume that your GitHub token is set in the environment:

export GITHUB_TOKEN=a345fd8e93...

Download latest artifact called "stuff" to a local file called stuff.zip

github-artifact-download.py owner/repo --artifact stuff

Download latest artifact called "stuff" into a file called artifact.zip

github-artifact-download.py owner/repo --artifact stuff --filename artifact.zip

Download latest artifact called "stuff" and make sure we don't download it again

github-artifact-download.py owner/repo --artifact stuff --cache-file id.txt

Download the artifact "stuff" from the last successful build of workflow "My Test Build"

github-artifact-download.py owner/repo --artifact stuff --workflow "My Test Build"

Download the artifact "stuff" from the last successful build of workflow "My Test Build", but only for builds on branch "test-build"

github-artifact-download.py owner/repo --artifact stuff --workflow "My Test Build" --branch test-build

Get help

github-artifact-download.py --help

github-artifact-download's People

Contributors

mawe42 avatar

Watchers

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