Coder Social home page Coder Social logo

upload-to-release's Introduction

Upload to Release

A GitHub Action that uploads a file to a new release.

Usage

This action uploads any file to a new release:

image

One example workflow is to build and save a Docker image then upload it to a release:

# .github/workflows/build-docker-image.yml
name: build-docker-image

on: release

jobs:
  build-docker-image:
    name: Build and upload docker image
    runs-on: ubuntu-latest
    steps:
      - name: Pull source
        uses: actions/checkout@v1

      - name: Build Docker image
        uses: actions/docker/cli@master
        with:
          args: build . -t my-image

      - name: Save the image
        uses: actions/docker/cli@master
        with:
          args: save my-image:latest

      - name: Upload to release
        uses: JasonEtco/upload-to-release@master
        with:
          args: my-image.tar
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Requirements

You must pass at least one argument, the path to the file you want to attach. You must also include the GITHUB_TOKEN secret, otherwise uploading the file will not work.

- name: Upload to release
  uses: JasonEtco/upload-to-release@master
  with:
    args: my-image.tar
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Content-Type

You may also need to pass an additional argument, the Content-Type header used when uploading your file (this is application/zip by default):

- name: Upload to release
  uses: JasonEtco/upload-to-release@master
  with:
    args: my-image.tar application/zip
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Event type

The event type your workflow is triggered from is critical to the function of this action. If you are not using on: release for your workflow this action will not work correctly.

The event sent to the action by GitHub only contains an artifact upload URL when using the release event type to trigger the workflow.

If you need other workflows not based on the release event, you should use multiple workflow definitions.

upload-to-release's People

Contributors

jasonetco avatar nadock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

upload-to-release's Issues

Upload multiple files with single run of action

Even though you could just run the action over and over again to upload all the files you want, it may be easier to push all of the files you want in one swoop.

I'm imagining where you may compile binaries for Windows, Linux, and Mac, so you have at least 3 files to be pushed up.

curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104

Hi, I'm getting this error randomly in every 1 out of 3 runs.

Run JasonEtco/upload-to-release@master
  with:
    args: app.zip application/zip
  env:
    GOROOT: /opt/hostedtoolcache/go/1.16.14/x64
    GITHUB_TOKEN: ***
/usr/bin/docker run --name db[2](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:2)d710277bad0191448eb5e85b84bf110bf5_4547[3](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:3)0 --label 7db2d7 --workdir /github/workspace --rm -e GOROOT -e GITHUB_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/REPO/app":"/github/workspace" 7db2d7:10277bad0191[4](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:4)48eb[5](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:5)e85b84bf110bf5 app.zip application/zip
https://uploads.github.com/repos/ORG/REPO/releases/[6](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:6)024153[8](https://github.com/ORG/REPO/runs/5357285292?check_suite_focus=true#step:7:8)/assets?name=app.zip
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104

Getting error 400 Not Found

Hi, I'm trying to use your extension in this workflow. I've tested and the file does indeed exist, so I was wonder you knew what was up?

Run JasonEtco/upload-to-release@master
  with:
    args: slyblime.zip
  env:
    GITHUB_TOKEN: ***
/usr/bin/docker run --name e44b6bdb9d1eae47afa8bbe864f34e5580_339586 --label 5588e4 --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/slyblime-test-repo-do-not-use/slyblime-test-repo-do-not-use":"/github/workspace" 5588e4:4b6bdb9d1eae47afa8bbe864f34e5580 slyblime.zip
https://uploads.github.com/repos/s-clerc/slyblime-test-repo-do-not-use/releases/40587859/assets?name=slyblime.zip
curl: (22) The requested URL returned error: 400 ```

The action doesn't fail when API call fails

Hi ๐Ÿ‘‹ thanks for your work! We're using this as part of our release workflow, and noticed today that the GitHub API upload call returned a Not found. We've never seen this before, and couldn't reproduce the issue, but it showed us that the action finished successfully. We expect that the action should fail here if the API call fails.

Logs:

> Run JasonEtco/upload-to-release@master
/usr/bin/docker run --name dfbe11167ca24c24fd4bc70170aa97ccebd_658105 --label 488dfb --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/insights-releases/insights-releases":"/github/workspace" 488dfb:e11167ca24c24fd4bc70170aa97ccebd installation.tgz application/gzip
https://uploads.github.com/repos/github/insights-releases/releases/22876496/assets?name=installation.tgz
{"message":"Not Found","request_id":"07C0:4090:4A70F:5CE27:5E1F9B63","documentation_url":"https://developer.github.com/v3"}

Workflow question

Do I understand correctly that you can create a file artifact in one Action of the workflow and it's preserved and available in the containers of subsequent Actions?

Getting the tag name of release

I have this workflow:

name: Publish the Debian Package

on:
  release:
    types: [published]

jobs:
  publish-deb-package:
    name: Build and publish the Debian package
    runs-on: ubuntu-latest
    container:
      image: docker://dragoncomputer/dragonfire:latest

    steps:
      - uses: actions/checkout@v1

      - name: Cache pip packages
        uses: actions/cache@v1
        with:
          path: /root/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Install dependencies
        run: |
          pip3 install -e .

      - name: Generate the Debian package
        run: |
          dpkg-buildpackage -us -uc
          cd ..
          echo ${{ github.ref }} | cut -c12- | { read version; }

      - name: Upload to release
        uses: JasonEtco/upload-to-release@master
        with:
          args: dragonfire_${version}_amd64.deb
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

With echo ${{ github.ref }} | cut -c12- | { read version; } I aim to get 1.0.7 from refs/tags/v1.0.7(which is the output of the value of github.ref) but passing to args: seems impossible. dragonfire_${version}_amd64.deb resolves into dragonfire_${version}_amd64.deb while either dragonfire_1.0.7_amd64.deb or dragonfire__amd64.deb expected.

How can I achieve what I'm trying to achieve here?

Questions about this action

I would like to use this to add jar-files to my release, but I'm not really sure, how I could implement this, which is why I ask here.

I have a Java project, using Gradle and already have set up a GitHub Action, to upload files to a site called Bintray, therefore creating a workflow, that already generates the jar files.

My current setup of the workflow can be found here.
My current setup for Gradle can be found here.

I would appreciate any kind of help, to implement this, if possible.

Invalid Content-Type header

I have a workflow which runs on release, but when I create a pre-release, it is not able to upload the given file, stating "Invalid Content-Type ''". But by reading the Readme and source files, I know that Content-Type: application/zip (which is the mime type of the file I'm uploading) is added as a default. Can you please help me how to fix this?

Below is the snippet from Docker log.

https://uploads.github.com/repos/pavi2410/AIX-Action/releases/17777351/assets?name=tk.pavi2410.aix
{"message":"Invalid Content-Type: ''","request_id":"924E:7E0D:5E1F0:6B453:5CF6AD53"}

README examples use old Actions syntax

Re: the discussion in PR #9

The examples in the README.md use the old Actions syntax, suggest updating them to the new yaml based syntax.

On a related point, I think the README.md should also call out specifically that this action will only work with the release event type, not any other event type (like push for example).

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.