forked from ruslo/hunter
-
Notifications
You must be signed in to change notification settings - Fork 181
130 lines (107 loc) · 3.54 KB
/
ci.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI
on:
push:
paths: [ 'cmake/projects/**' ]
pull_request:
paths: [ 'cmake/projects/**' ]
workflow_dispatch:
inputs:
project:
description: 'Project name'
required: true
jobs:
set_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Manual dispatch, get project name from input
if: github.event_name == 'workflow_dispatch'
run: |
echo '["cmake/projects/${{ github.event.inputs.project }}/hunter.cmake"]' > ${HOME}/files.json
- name: Get changed files and save them to ${HOME}/files.json
if: github.event_name != 'workflow_dispatch'
id: files
uses: lots0logs/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set matrix for subsequent build
id: set-matrix
run: |
MATRIX=`python .github/workflows/set_matrix.py`
if [ "${MATRIX}" ]; then
echo "::set-output name=matrix::${MATRIX}"
else
exit 1
fi
build:
name: ${{ matrix.example }} ${{ matrix.toolchain }} ${{ matrix.os }}
needs: set_matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set_matrix.outputs.matrix) }}
env:
TOOLCHAIN: ${{ matrix.toolchain }}
PROJECT_DIR: examples/${{ matrix.example }}
GITHUB_USER_PASSWORD: ${{ secrets.CPP_PM_BOT_TOKEN }}
steps:
- name: Git checkout with submodules
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Set up Python environment variable (Unix)
if: runner.os != 'Windows'
run: echo "HUNTER_PYTHON_LOCATION=$pythonLocation" >> $GITHUB_ENV
- name: Set up Python environment variable (Windows)
if: runner.os == 'Windows'
run: echo "HUNTER_PYTHON_LOCATION=$env:pythonLocation" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
id: extract_branch
- name: Build on Unix
if: runner.os != 'Windows'
env:
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
run: |
bash ${{ matrix.script }}
- name: Build on Windows
if: runner.os == 'Windows'
env:
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
run: |
${{ matrix.script }}
set_status:
needs: [ set_matrix, build ]
if: always() && needs.set_matrix.result == 'success' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Get job status via GitHub API
uses: octokit/[email protected]
id: get_job_data
with:
route: GET /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Parse job status
run: |
mkdir job_data
echo '${{ steps.get_job_data.outputs.data }}' > job_data.json
python .github/workflows/set_status.py
- name: Deploy job status to GitHub Pages
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: job_data
destination_dir: _data/projects
keep_files: true
enable_jekyll: true