Skip to content

Commit

Permalink
chore(release): add release please to gh actions (DEV-690) (#193)
Browse files Browse the repository at this point in the history
* chore(editor): setup indent size for yaml file

* chore(docker): update docker file

* chore(build): same build process as in DSP-APP

* chore(build): add makefile and vars

* chore(gh-action): add release please

* chore(gh-actions): do not use matrix strategy

* fix(docker): fix the build

* refactor(gh-action): split test and build into two steps

* chore(deps): update packages

* fix(gh-actions): use default GITHUB_TOKEN

* fix(release-please): add changelog file

* chore: set correct version

* refactor: resolve dead links

* chore(docker): publish on daschswiss docker hub

* chore(gh-actions): use the right gh token
  • Loading branch information
kilchenmann committed Mar 23, 2022
1 parent 1dbd0ca commit f95c55e
Show file tree
Hide file tree
Showing 10 changed files with 4,835 additions and 3,460 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -21,3 +21,6 @@ indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
93 changes: 74 additions & 19 deletions .github/workflows/main.yml
@@ -1,24 +1,79 @@
name: CI
env:
NV: 12.x # node version

on:
push:
push:
release:
types: [published]

jobs:
build-test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 12.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run Unit Tests
run: npm run test-ci
- name: Build app
run: docker build .

test:
name: Test the app
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Node.js ${{ env.NV }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NV }}
- name: Install dependencies
run: npm install
- name: Run Unit Tests
run: npm run test-ci

build:
name: Build the app
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Node.js ${{ env.NV }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NV }}
- name: Install dependencies
run: npm install
- name: Build in prod mode
run: docker build .

release-please:
name: Prepare next release
runs-on: ubuntu-latest
# Automate releases with Conventional Commit Messages as Pull Requests are merged into "develop" branch
if: github.ref == 'refs/heads/develop'
steps:
- name: Get release please action
uses: GoogleCloudPlatform/release-please-action@v2
with:
token: ${{ secrets.GH_TOKEN }}
release-type: node
package-name: beol
changelog-types: '[
{"type": "feat", "section": "Enhancements", "hidden": false },
{"type": "fix", "section": "Bug Fixes", "hidden": false },
{"type": "chore", "section": "Maintenance", "hidden": false },
{"type": "refactor", "section": "Maintenance", "hidden": false },
{"type": "docs", "section": "Documentation", "hidden": false }
]'

# publish only on release
publish:
name: Publish to Dockerhub
needs: [
build,
test
]
runs-on: ubuntu-latest
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout source
uses: actions/checkout@v1
with:
fetch-depth: 50
- name: Build and publish image
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin
make publish-beol-image
Empty file added CHANGELOG.md
Empty file.
4 changes: 2 additions & 2 deletions Dockerfile
Expand Up @@ -31,9 +31,9 @@ RUN npm run build-prod

### STAGE 2: Setup ###

FROM dhlabbasel/nginx-server:v1.0.1
FROM daschswiss/nginx-server:v1.1.1

LABEL maintainer="ivan.subotic@unibas.ch"
LABEL maintainer="400790+subotic@users.noreply.github.com"

RUN rm -rf /public/*

Expand Down
25 changes: 25 additions & 0 deletions Makefile
@@ -0,0 +1,25 @@
# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
# THIS_FILE := $(lastword $(MAKEFILE_LIST))
THIS_FILE := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

include vars.mk

#################################
# Build and publish targets
#################################
.PHONY: build-beol-image
build-beol-image: ## build BEOL APP image locally
docker build -t $(BEOL_IMAGE) .
docker tag $(BEOL_IMAGE) $(BEOL_REPO):latest

.PHONY: publish-beol-image
publish-beol-image: build-beol-image ## publish BEOL APP Docker image to Docker-Hub
docker image push --all-tags $(BEOL_REPO)

.PHONY: help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.DEFAULT_GOAL := help

0 comments on commit f95c55e

Please sign in to comment.