-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,91 @@ | ||
name: C/C++ CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
on: [push, pull_request] | ||
#on: | ||
# push: | ||
# pull_request: | ||
# schedule: | ||
# # run 9:00 UCT time every date, i.e. 17:00 Taipei time | ||
# - cron: '0 9 * * *' | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: gcc | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: compile with gcc | ||
run: gcc helloworld.c | ||
|
||
- name: store compilation result | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: executable | ||
path: a.out | ||
|
||
- name: Get current date | ||
id: date | ||
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 }}_${{ steps.branch.outputs.branch }} | ||
path: a.out | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.branch.outputs.branch }}_${{ steps.date.outputs.date }} | ||
release_name: ${{ steps.branch.outputs.branch }}_${{ steps.date.outputs.date }} | ||
draft: false | ||
prerelease: false | ||
|
||
- 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 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 }}_${{ steps.branch.outputs.branch }}_${{ steps.date.outputs.date }} | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Send mail | ||
if: always() | ||
uses: dawidd6/action-send-mail@v3 | ||
with: | ||
# mail server settings | ||
server_address: smtp-mail.outlook.com | ||
server_port: 587 | ||
# user credentials | ||
username: ${{ secrets.EMAIL_USERNAME }} | ||
password: ${{ secrets.EMAIL_PASSWORD }} | ||
# email subject | ||
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }} | ||
# 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> | ||
<tr><td> release url </td><td>${{ steps.create_release.outputs.html_url }}</td></tr> | ||
</table> | ||
# comma-separated string, send email to | ||
to: ferrywu@arimacomm.com.tw | ||
# from email name | ||
from: github-${{ github.repository_owner }} | ||
|