-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (81 loc) · 3.65 KB
/
c-cpp.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: C/C++ CI
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:
- 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 triggered by </td><td><font color="#3366BB">${{ github.actor }}</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
# from email name
from: github-${{ github.repository_owner }}