-
Notifications
You must be signed in to change notification settings - Fork 102
70 lines (66 loc) · 2.49 KB
/
23-upload-release-asset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: 23 - Upload Release Asset
on:
# push:
workflow_dispatch:
inputs:
git-sha:
description: Release SHA
# default: ${{ env.GITHUB_SHA }}
required: true
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
outputs:
sha8: ${{steps.short_sha.outputs.sha8}}
short-sha: ${{steps.short_sha.outputs.short_sha}}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get input SHA
env:
SHA: ${{ github.event.inputs.git-sha }}
run: echo "SHA $SHA"
# For the sake of simplicity, we'll name the tag and the release with
# the first 8 chars of the commit SHA:
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
echo "::set-output name=short_sha::$(echo blah)"
- name: Build project # This would actually build your project, using zip for your example date artifact
run: |
date > date.txt
zip -rT app.zip date.txt
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Using short SHA from 2nd step for tag and release name.
tag_name: ${{steps.short_sha.outputs.sha8}}
release_name: ${{steps.short_sha.outputs.sha8}}
draft: false
prerelease: false
# Now we upload the artifact we generated in the first step to
# the release we created in the 3nd step
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./app.zip
asset_name: app.zip
asset_content_type: application/zip
post-build:
runs-on: ubuntu-latest
needs: build
if: ${{!startsWith(needs.build.outputs.sha8, needs.build.outputs.short-sha)}}
steps:
- name: echo previous job's output
run: |
echo sha8-${{needs.build.outputs.sha8}}
echo short_sha-${{needs.build.outputs.short-sha}}