mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-12-21 06:51:19 +08:00
87 lines
2.7 KiB
YAML
87 lines
2.7 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: Set up Docker
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
echo $DOCKER_CA_PEM >> $GITHUB_WORKSPACE/ca.pem.base64
|
|
echo $DOCKER_CERT >> $GITHUB_WORKSPACE/cert.pem.base64
|
|
echo $DOCKER_KEY >> $GITHUB_WORKSPACE/key.pem.base64
|
|
base64 -d $GITHUB_WORKSPACE/ca.pem.base64 >> $GITHUB_WORKSPACE/ca.pem
|
|
base64 -d $GITHUB_WORKSPACE/cert.pem.base64 >> $GITHUB_WORKSPACE/cert.pem
|
|
base64 -d $GITHUB_WORKSPACE/key.pem.base64 >> $GITHUB_WORKSPACE/key.pem
|
|
alias secure-docker="docker -H tcp://bender.minidigger.me:4243 --tlsverify --tlscacert=$GITHUB_WORKSPACE/ca.pem --tlscert=$GITHUB_WORKSPACE/cert.pem --tlskey=$GITHUB_WORKSPACE/key.pem"
|
|
|
|
- name: Docker
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
cd docker/deployment
|
|
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
docker-compose build
|
|
docker-compose push
|
|
secure-docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
secure-docker stack deploy --with-registry-auth --compose-file=docker-compose.yml hangar_new
|