Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

upload_url for GitHub's upload-release-asset action when the trigger is a release?

I am trying to create a GitHub Action that is triggered when a release is published and will build my project and upload certain artefacts as release assets. The only examples I can find rely on using the create-release action, which fails as the release has already been created. My workflow file is like so:

name: Build for Release

on:
  release:
    types: [published]

jobs:
  build:

    runs-on: macos-latest

    steps:
    - uses: actions/checkout@v2
      
    - name: Build
      run: ...
      
    - name: Zip Asset
      run: ...

    - name: Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ ???? What Goes Here ???? }}
        asset_path: build/MyProject.zip
        asset_name: MyProject.zip
        asset_content_type: application/zip

My tags will be v0.1.0, v0.1.1, v0.2.0 etc and the release name matches these.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can access it on the event data in the github context:

- name: Upload Release Asset
  uses: actions/upload-release-asset@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    upload_url: ${{ github.event.release.upload_url }}

See also Example data for the release event.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...