Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): add release please to gh actions (DEV-690) #193

Merged
merged 15 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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.GITHUB_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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Loading