Hangar/.github/workflows/deploy.yml
MiniDigger 5aaf42ce28 🤦‍♂️
Signed-off-by: MiniDigger <admin@benndorf.dev>
2021-10-16 18:20:06 +02:00

96 lines
2.9 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
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
SSO_CLIENT_ID: ${{ secrets.SSO_CLIENT_ID }}
SSO_SECRET: ${{ secrets.SSO_SECRET }}
API_KEY: ${{ secrets.API_KEY }}
TOKEN_SECRET: ${{ secrets.TOKEN_SECRET }}
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