Skip to content

Commit

Permalink
Update c-cpp.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrywu authored Nov 17, 2021
1 parent 5653598 commit 8b2eed9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: C/C++ CI

#on: [push, pull_request]
on:
push:
pull_request:
Expand All @@ -26,15 +27,18 @@ jobs:

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d_%H-%M-%S')"
run: echo "::set-output name=date::$(env TZ=Asia/Taipei date +'%Y-%m-%d_%H-%M-%S')"
- name: Get respository name
id: repository_name
run: echo "::set-output name=repository_name::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
- name: Get current branch
id: branch
run: echo "::set-output name=branch::$(echo '${{ github.ref }}' | awk -F '/' '{print $NF}')"

- name: Upload build output
uses: actions/upload-artifact@v2
with:
name: ${{ steps.repository_name.outputs.repository_name }}
name: ${{ steps.repository_name.outputs.repository_name }}-${{ steps.branch.outputs.branch }}
path: a.out

- name: Create Release
Expand All @@ -43,8 +47,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.date.outputs.date }}
release_name: ${{ steps.date.outputs.date }}
tag_name: ${{ steps.branch.outputs.branch }}-${{ steps.date.outputs.date }}
release_name: ${{ steps.branch.outputs.branch }}-${{ steps.date.outputs.date }}
draft: false
prerelease: false

Expand All @@ -56,7 +60,7 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's 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: ${{ github.workspace }}/a.out
asset_name: ${{ steps.repository_name.outputs.repository_name }}
asset_name: ${{ steps.repository_name.outputs.repository_name }}-${{ steps.branch.outputs.branch }}
asset_content_type: application/octet-stream

- name: Send mail
Expand All @@ -74,6 +78,7 @@ jobs:
# email body as text
html_body: <h1> Build ${{ job.status }} </h1></br>
<table>
<tr><td> branch </td><td><font color="#3366BB">${{ steps.branch.outputs.branch }}</font></td></tr>
<tr><td> build commit message </td><td><font color="#3366BB">${{ github.event.head_commit.message }}</font></td></tr>
<tr><td> build commit </td><td>https://github.com/${{ github.repository }}/commit/${{ github.sha }}</td></tr>
<tr><td> build url </td><td>https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}</td></tr>
Expand Down

0 comments on commit 8b2eed9

Please sign in to comment.