This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
Update plugin org.jetbrains.kotlin.jvm to v1.9.0 #148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Kryptokrona API Pull Request Pipeline | |
on: | |
pull_request: | |
paths-ignore: | |
- 'monitor/**' | |
jobs: | |
ansible-syntax-check: | |
name: Ansible Syntax Check | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# Install python3 pip and ansible latest | |
- name: Install python and ansible | |
run: sudo apt update && sudo apt install -y python3-pip && sudo pip3 install ansible | |
# If `roles` folder exists, create a playbook_repo.yml playbook to perform the syntax check | |
- name: Creating playbook_repo.yml from roles folder (if exists) | |
run: test -d "kryptokrona-api/ansible/roles" || exit 0 && echo $LINE1 > playbook_repo.yml && echo $LINE2 >> playbook_repo.yml && printf " roles:\n" >> playbook_repo.yml && for i in `ls kryptokrona-api/ansible/roles`; do echo " - $i" >> playbook_repo.yml; done | |
env: | |
LINE1: "---" | |
LINE2: "- hosts: localhost" | |
# Check ansible syntax if roles folder exists (repo with playbooks and roles) | |
- name: Ansible Syntax Check of all roles of the playbook | |
run: test -f "playbook_repo.yml" || exit 0 && ansible-playbook $GITHUB_WORKSPACE/playbook_repo.yml --syntax-check | |
env: | |
ANSIBLE_ACTION_WARNINGS: False | |
# If `roles` folder does not exist, assume we are in a repository containing just the role | |
- name: Creating role_repo.yml from roles folder (if exists) | |
run: test -d "tasks" || exit 0 && echo $LINE1 > /tmp/role_repo.yml && echo $LINE2 >> /tmp/role_repo.yml && printf " roles:\n" >> /tmp/role_repo.yml && printf " - `echo $GITHUB_REPOSITORY | tr "/" "\n" | tail -1`\n" >> /tmp/role_repo.yml | |
env: | |
LINE1: "---" | |
LINE2: "- hosts: localhost" | |
# Copy the repo content for syntax check | |
- name: Copy the repo content to /tmp/ for syntax check | |
run: test -f "/tmp/role_repo.yml" || exit 0 && mkdir -p /tmp/roles/ && cd .. && cp -a `echo $GITHUB_REPOSITORY | tr "/" "\n" | tail -1` /tmp/roles/ | |
# Check ansible syntax if tasks folder exists (repo with just the role) | |
- name: Ansible Syntax Check of role | |
run: test -f "/tmp/role_repo.yml" || exit 0 && ANSIBLE_ROLES_PATH=/tmp/roles ansible-playbook /tmp/role_repo.yml --syntax-check | |
env: | |
ANSIBLE_ACTION_WARNINGS: False | |
assemble: | |
name: Assemble | |
runs-on: ubuntu-latest | |
needs: [ ansible-syntax-check ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up OpenJDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Assemble | |
run: ./gradlew assemble | |
- name: Upload Build Directory Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-dir | |
path: ./build | |
unit-test: | |
name: Unit Test | |
runs-on: ubuntu-latest | |
needs: [ assemble ] | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: kryptokrona_api_dev | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: test1234 | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up OpenJDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Run Liquibase Migrations | |
run: ./gradlew update -PdbEnv=dev | |
- name: Run Unit Test | |
run: ./gradlew test | |
docker: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
needs: [ unit-test ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: benjlevesque/short-sha@v2.2 | |
- name: Download Build Directory | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-dir | |
path: ./build | |
- name: Build Docker | |
run: | | |
docker build . --no-cache |