This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (82 loc) · 2.79 KB
/
build-publish.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
name: Build and publish
env:
cache-name: cache-build
context: ./
on:
push:
branches: [ main ]
tags: '*'
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 17.x, 18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn coverage
- name: Coveralls
uses: coverallsapp/github-action@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: '${{ env.context }}coverage/lcov.info'
base-path: '${{ env.context }}'
- name: Compile file and build
if: ${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.base_ref == 'main') && matrix.node-version == '16.x' }}
run: yarn build
- name: Cache build
if: ${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.base_ref == 'main') && matrix.node-version == '16.x' }}
uses: actions/cache@v2
with:
path: ${{ env.context }}build
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
docker-build:
name: Build docker
needs: test
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=microlc/micro-lc-redoc-plugin
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
VERSION=$(echo ${VERSION} | sed s/^v//)
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=latest
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=image::${DOCKER_IMAGE}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.BOT_DOCKER_USERNAME }}
password: ${{ secrets.BOT_DOCKER_TOKEN }}
- name: Cache build
uses: actions/cache@v2
with:
path: ${{ env.context }}build
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: '${{ env.context }}'
push: true
tags: ${{ steps.prep.outputs.tags }}