Repository navigation
183 lines (181 loc) · 6.14 KB
/
Copy pathci.yml
File metadata and controls
183 lines (181 loc) · 6.14 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: CI
on: [push]
env:
PYTHON_VERSION: "3.8"
NODE_VERSION: "12"
jobs:
lint-custom:
name: Lint Custom
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Custom Lint
run: find . -type f -name '*.sh' -exec scripts/lint.sh --debug {} \;
lint-shell:
name: Lint Shell Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@0.3.0
with:
check_together: "yes"
lint-vim:
name: Lint Vim Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Vint
run: pip install vim-vint
- name: Run Vint
run: vint nvim/*.vim
lint-json:
name: Lint JSON Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install JSON Lint
run: npm install -g jsonlint
- name: Run JSON Lint
run: find . -type f -name '*.json' -exec jsonlint -q -c {} \;
lint-yaml:
name: Lint YAML Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install YAML Lint
run: pip install yamllint
- name: Run YAML Lint
run: yamllint .
lint-docker:
name: Lint Dockerfiles
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Hadolint
uses: brpaz/hadolint-action@master
setup-macos:
name: Setup on MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run setup
run: scripts/setup.sh --debug
setup-linux:
name: Setup on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Remove Fonts
run: sudo rm -rf /usr/share/fonts/cmap
- name: Prepare
id: prep
run: |
echo ::set-output name=home::${HOME}
- name: Cache Brew Cache
uses: actions/cache@v2
env:
base-key: ${{ runner.os }}-build-brew-cache
cache-path: ${{ steps.prep.outputs.home }}/.cache/Homebrew
with:
path: ${{ env.cache-path }}
key: ${{ env.base-key }}-${{ hashFiles('**/Brewfile') }}
restore-keys: |
${{ env.base-key }}-
- name: Run setup
run: scripts/setup.sh --debug
docker:
name: Docker Build and Push
runs-on: ubuntu-latest
needs: [lint-custom, lint-shell, lint-docker]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Repo Metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: Prepare
id: prep
run: |
REGISTRY='ghcr.io'
DOCKER_IMAGE_NAME="${{ github.repository }}"
DOCKER_IMAGE="${REGISTRY}/${DOCKER_IMAGE_NAME}"
VERSION='noop'
CHANNEL='stable'
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=registry::${REGISTRY}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
- name: Cache Image Layers
uses: actions/cache@v2
env:
base-key: ${{ runner.os }}-build-docker-buildx
cache-path: /tmp/.buildx-cache
with:
path: ${{ env.cache-path }}
key: ${{ env.base-key }}-${{ github.sha }}
restore-keys: |
${{ env.base-key }}-
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ steps.prep.outputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and Push to GitHub Container Registry
uses: docker/build-push-action@v2
with:
push: ${{ github.event_name != 'pull_request' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || contains(github.ref, 'refs/tags')) }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}