-
Notifications
You must be signed in to change notification settings - Fork 51
133 lines (115 loc) · 4.42 KB
/
build.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
name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
branches:
- master
types:
- published
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/${{ secrets.GHCR_IMAGE_NAME }}
jobs:
lint:
name: Lint code using eslint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install Node.js 10
uses: actions/setup-node@v3
with:
node-version: 10
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: |
~/.npm
~/.cache/bower
app/bower_components
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install project dependencies
run: |
npm ci
- name: Run eslint
run: |
npm run lint
build:
name: Build frontend
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install Node.js 10
uses: actions/setup-node@v3
with:
node-version: 10
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: |
~/.npm
~/.cache/bower
app/bower_components
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install project dependencies
run: |
npm ci && npx [email protected] install
- name: Prepare build environment variables
id: branch_info
run: |
branch_name=${GITHUB_REF##*/}
short_sha=${GITHUB_SHA:0:7}
echo "##[set-output name=branch_name;]${branch_name}"
echo "##[set-output name=short_sha;]${short_sha}"
if [ "$branch_name" = "master" || ${{ github.event_name == 'release' }} ]; then
echo "OPENSENSEMAP_API_URL=https://api.opensensemap.org" >> $GITHUB_ENV
echo "OPENSENSEMAP_CMS_URL=${{ secrets.OPENSENSEMAP_CMS_URL }}" >> $GITHUB_ENV
echo "OPENSENSEMAP_STYLE_URL=${{ secrets.OPENSENSEMAP_STYLE_URL }}" >> $GITHUB_ENV
echo "OPENSENSEMAP_ACCESS_TOKEN=${{ secrets.OPENSENSEMAP_ACCESS_TOKEN }}" >> $GITHUB_ENV
else
echo "OPENSENSEMAP_API_URL=https://api.testing.opensensemap.org" >> $GITHUB_ENV
echo "OPENSENSEMAP_CMS_URL=${{ secrets.OPENSENSEMAP_CMS_URL }}" >> $GITHUB_ENV
echo "OPENSENSEMAP_STYLE_URL=${{ secrets.OPENSENSEMAP_STYLE_URL }}" >> $GITHUB_ENV
echo "OPENSENSEMAP_ACCESS_TOKEN=${{ secrets.OPENSENSEMAP_ACCESS_TOKEN_TESTING }}" >> $GITHUB_ENV
fi
# - name: Update version in package.json
# if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
# run: |
# npm version ${{ github.event.release.tag_name }} --no-git-tag-version --no-commit-hooks
- name: Build
run: |
npx grunt build --target=build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Github Container Registry (ghcr)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build container image and push to Docker Hub (not for PRs)
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name == 'push' || ( github.event_name == 'release' && github.event.action == 'published' ) }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.branch_info.outputs.branch_name }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.branch_info.outputs.branch_name }}-${{ steps.branch_info.outputs.short_sha }}
context: ./
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
provenance: false # https://github.com/docker/buildx/issues/1533