-
Notifications
You must be signed in to change notification settings - Fork 74
166 lines (142 loc) · 5.35 KB
/
ci.yaml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CI
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: ['19', '18', '16', '14']
os: ['windows-latest', 'ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}
name: Node ${{ matrix.node-version }} sample (${{ matrix.os }})
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get NPM Cache Directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache NPM
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM Dependencies
run: npm ci
- name: Setup Python for Github-Markup
if: ${{ runner.os != 'Windows' }}
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install docutils for Github-Markup
if: ${{ runner.os != 'Windows' }}
run: |
python -m pip install --upgrade pip
pip install docutils
- name: Setup Licensee, Linguist, and Github-Markup Dependencies (MacOS)
if: ${{ runner.os == 'macOS' }}
run: brew install cmake pkg-config icu4c libidn
- name: Setup Licensee, Linguist, and Github-Markup Dependencies (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update
sudo apt-get install -y build-essential libicu-dev libcurl4-openssl-dev libldap2-dev libidn11-dev
- name: Setup Ruby
if: ${{ runner.os != 'Windows' }}
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1.4'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run Test
if: ${{ runner.os != 'Windows' }}
run: bundle exec npm test
- name: Run Test (Windows)
if: ${{ runner.os == 'Windows' }}
run: npm test
test-docker:
runs-on: ubuntu-latest
name: Docker sample
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Build
uses: docker/build-push-action@v2
with:
tags: todogroup/repolinter:latest
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Docker Run
run: docker run -t -v ${{ github.workspace }}:/src -w /src todogroup/repolinter:latest .
publish-release:
name: Publish a Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
needs: [test, test-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v2
with:
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Cache Docker layers
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
if: steps.semantic.outputs.new_release_published == 'true'
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
if: steps.semantic.outputs.new_release_published == 'true'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Gather Docker Labels
if: steps.semantic.outputs.new_release_published == 'true'
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: ghcr.io/${{ github.repository }}
- name: Build and Push to GitHub Container Registry
if: steps.semantic.outputs.new_release_published == 'true'
uses: docker/build-push-action@v2
with:
context: .
push: true
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: >-
ghcr.io/${{ github.repository }}:latest,
ghcr.io/${{ github.repository }}:v${{ steps.semantic.outputs.new_release_major_version }}.${{ steps.semantic.outputs.new_release_minor_version }},
ghcr.io/${{ github.repository }}:v${{ steps.semantic.outputs.new_release_major_version }}.${{ steps.semantic.outputs.new_release_minor_version }}.${{ steps.semantic.outputs.new_release_patch_version }}