mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-12-21 06:51:19 +08:00
4f18eaa131
* initial attempt * change names
86 lines
2.4 KiB
YAML
86 lines
2.4 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
# allow manual dispatch
|
|
workflow_dispatch:
|
|
# run on PRs
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
concurrency:
|
|
group: ${{ github.ref }}-deploy
|
|
cancel-in-progress: true
|
|
|
|
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
|
|
|
|
- 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
|
|
# keep these in sync with compose!
|
|
proxyHost: "http://hangar_new_backend:8080"
|
|
authHost: "http://hangar_new_auth:8000"
|
|
host: "0.0.0.0"
|
|
PUBLIC_HOST: "https://hangar.benndorf.dev"
|
|
run: (cd frontend && yarn build)
|
|
|
|
- name: SSH
|
|
uses: webfactory/ssh-agent@v0.5.2
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
with:
|
|
ssh-private-key: ${{ secrets.DOCKER_HOST_SSH_KEY }}
|
|
|
|
- name: Docker
|
|
run: |
|
|
echo ${{ secrets.DOCKER_HOST_SSH_SIG }} > ~/.ssh/known_hosts
|
|
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
|