Hangar/.github/workflows/build.yml
MiniDigger 8417acefb9 try to deploy using ssh
Signed-off-by: MiniDigger <admin@minidigger.me>
2021-03-15 19:37:18 +01:00

80 lines
2.1 KiB
YAML

name: Deploy
on:
# allow manual dispatch
workflow_dispatch:
# run on PRs
push:
branches:
- nuxt-frontend # todo test
pull_request:
branches:
- nuxt-frontend
#- master TODO: once nuxt is merged, change this back
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '12'
- name: Cache Maven Deps
uses: actions/cache@v2
with:
path: $GITHUB_WORKSPACE/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build backend
run: mvn --batch-mode --errors --fail-at-end --show-version --no-transfer-progress -Dmaven.repo.local=$GITHUB_WORKSPACE/.m2/repository install -DskipTests # todo fix tests
- name: Cache Yarn
uses: actions/cache@v2
with:
path: "~/.cache/yarn"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install frontend deps
env:
CI: true
run: (cd frontend && yarn install --frozen-lockfile --cache-folder ~/.cache/yarn)
- name: Lint frontend
env:
CI: true
run: (cd frontend && yarn lint)
- name: Build frontend
env:
CI: true
run: (cd frontend && yarn build)
- name: SSH
uses: webfactory/ssh-agent@v0.5.1
with:
ssh-private-key: ${{ secrets.DOCKER_HOST_SSH_KEY }}
- name: Docker
if: github.event_name == 'push'
run: |
cd docker/deployment
echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
docker-compose build
docker-compose push
DOCKER_HOST="${{ secrets.DOCKER_HOST }}" docker stack deploy --with-registry-auth --compose-file=docker-compose.yml hangar_new