Skip to content

v3.5.0

v3.5.0 #342

Workflow file for this run

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 bower@1.8.8 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