Is it possible for Github actions to upload a build artifact for commits on a release branch, and then for another workflow to download & use that artifact?
name: Deploy release to UAT & archive artifact
on:
release:
types: [published]
jobs:
package:
name: package and archive
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: serverless package
uses: serverless/github-action@master
with:
args: package --stage=prod
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: .serverless
asset_name: release-asset-${{ github.event.release.name }}.zip
asset_content_type: application/zip
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: release-artifact-${{ github.event.release.name }}
path: .serverless
...but how do you download the asset/artifact? I think up/download-artifact
is intended only to be used only from the same workflow, and there doesn't seem to be an action for downloading a release asset.
name: Deploy to production
on:
workflow_dispatch:
inputs:
release:
description: Name of release to deploy
required: true
default: v1.0.0
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- run: npm ci --only=prod
- name: Download the release artifact
uses: actions/download-artifact@v2
with:
name: release-${{ github.event.inputs.release }}
path: .serverless
- name: serverless deploy
uses: serverless/github-action@master
with:
args: deploy --stage=prod --package=.serverless
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
You can use download-workflow-artifact
action.
One of my team mates got this working:
- id: download-release-asset
name: Download release asset
uses: dsaltares/fetch-gh-release-asset@master
with:
version: tags/${{ env.RELEASE }}
file: myproject-${{ env.RELEASE }}.tar.gz
target: release.tar.gz
token: ${{ secrets.DEPLOY_TOKEN }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With