2021-02-06 02:04:28 +08:00
|
|
|
name: Deploy
|
2021-02-05 23:45:53 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
# allow manual dispatch
|
|
|
|
workflow_dispatch:
|
2021-02-06 02:07:58 +08:00
|
|
|
# run on PRs
|
2021-02-06 00:30:57 +08:00
|
|
|
push:
|
2021-02-06 02:07:58 +08:00
|
|
|
branches:
|
2021-04-17 15:28:41 +08:00
|
|
|
- master
|
2021-06-01 14:11:08 +08:00
|
|
|
|
|
|
|
concurrency:
|
2021-12-04 01:25:37 +08:00
|
|
|
group: ${{ github.ref }}
|
2021-06-01 14:11:08 +08:00
|
|
|
cancel-in-progress: true
|
2021-02-05 23:45:53 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2022-06-29 03:12:44 +08:00
|
|
|
with:
|
|
|
|
submodules: true
|
2021-02-05 23:45:53 +08:00
|
|
|
|
|
|
|
- name: Set up JDK
|
|
|
|
uses: actions/setup-java@v1
|
|
|
|
with:
|
2021-12-23 20:34:01 +08:00
|
|
|
java-version: 17
|
2021-02-05 23:45:53 +08:00
|
|
|
|
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
2021-12-23 20:34:01 +08:00
|
|
|
node-version: '16'
|
2021-02-05 23:45:53 +08:00
|
|
|
|
2022-03-21 20:41:17 +08:00
|
|
|
- name: Set up pnpm
|
|
|
|
uses: pnpm/action-setup@v2.1.0
|
|
|
|
with:
|
2022-07-09 18:11:52 +08:00
|
|
|
version: 7
|
2022-03-21 20:41:17 +08:00
|
|
|
|
2021-02-06 02:07:58 +08:00
|
|
|
- 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
|
2021-04-17 15:57:45 +08:00
|
|
|
run: mvn --batch-mode --errors --fail-at-end --show-version --no-transfer-progress -Dmaven.repo.local=$GITHUB_WORKSPACE/.m2/repository install
|
2021-02-06 02:07:58 +08:00
|
|
|
|
2022-03-21 20:41:17 +08:00
|
|
|
- name: Cache pnpm
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: "~/.pnpm-store"
|
|
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-
|
|
|
|
|
2021-02-06 02:07:58 +08:00
|
|
|
- name: Install frontend deps
|
2022-03-21 20:41:17 +08:00
|
|
|
env:
|
|
|
|
CI: true
|
2022-06-19 07:00:21 +08:00
|
|
|
run: (cd frontend && pnpm install --frozen-lockfile && cd server && pnpm install --frozen-lockfile)
|
2022-03-21 20:41:17 +08:00
|
|
|
|
2021-02-06 02:07:58 +08:00
|
|
|
- name: Lint frontend
|
2022-03-21 20:41:17 +08:00
|
|
|
env:
|
|
|
|
CI: true
|
2022-06-19 07:00:21 +08:00
|
|
|
run: (cd frontend && pnpm lint:eslint)
|
2022-03-21 20:41:17 +08:00
|
|
|
|
2022-06-19 07:04:45 +08:00
|
|
|
# - name: Sync forth and back with crowdin
|
|
|
|
# uses: crowdin/github-action@1.4.0
|
|
|
|
# with:
|
|
|
|
# upload_sources: true
|
|
|
|
# download_translations: true
|
|
|
|
# push_translations: false
|
|
|
|
# create_pull_request: false
|
|
|
|
# skip_untranslated_strings: true
|
|
|
|
# config: 'crowdin.yml'
|
|
|
|
# crowdin_branch_name: master
|
|
|
|
# env:
|
|
|
|
# CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
2021-12-19 18:59:02 +08:00
|
|
|
|
2021-02-06 02:07:58 +08:00
|
|
|
- name: Build frontend
|
|
|
|
env:
|
|
|
|
CI: true
|
2021-03-17 02:12:13 +08:00
|
|
|
# keep these in sync with compose!
|
2022-07-29 03:10:20 +08:00
|
|
|
BACKEND_HOST: "http://hangar_backend:8080"
|
|
|
|
AUTH_HOST: "https://hangar-auth.benndorf.dev"
|
2021-04-02 20:59:32 +08:00
|
|
|
PUBLIC_HOST: "https://hangar.benndorf.dev"
|
2022-07-29 17:42:38 +08:00
|
|
|
DEBUG: "hangar:*"
|
2022-06-19 07:00:21 +08:00
|
|
|
run: (cd frontend && pnpm build && cd server && pnpm build)
|
2022-03-21 20:41:17 +08:00
|
|
|
|
2021-03-16 02:37:18 +08:00
|
|
|
- name: SSH
|
2021-04-07 18:46:54 +08:00
|
|
|
uses: webfactory/ssh-agent@v0.5.2
|
2021-04-23 05:05:20 +08:00
|
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
2021-03-16 02:37:18 +08:00
|
|
|
with:
|
|
|
|
ssh-private-key: ${{ secrets.DOCKER_HOST_SSH_KEY }}
|
|
|
|
|
2022-03-26 04:03:16 +08:00
|
|
|
# I am not convinced that this is actually faster...
|
|
|
|
# - name: Cache Docker Layers
|
|
|
|
# uses: satackey/action-docker-layer-caching@v0.0.11
|
|
|
|
# continue-on-error: true
|
2022-01-29 22:48:41 +08:00
|
|
|
|
2021-02-06 02:26:05 +08:00
|
|
|
- name: Docker
|
2021-07-01 02:12:01 +08:00
|
|
|
env:
|
2021-07-01 02:34:27 +08:00
|
|
|
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
|
|
|
|
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
|
2021-10-17 00:20:06 +08:00
|
|
|
SSO_CLIENT_ID: ${{ secrets.SSO_CLIENT_ID }}
|
2022-07-29 03:10:20 +08:00
|
|
|
SSO_API_KEY: ${{ secrets.SSO_API_KEY }}
|
2021-07-01 05:19:04 +08:00
|
|
|
TOKEN_SECRET: ${{ secrets.TOKEN_SECRET }}
|
2021-02-06 02:04:28 +08:00
|
|
|
run: |
|
2021-03-16 02:50:20 +08:00
|
|
|
echo ${{ secrets.DOCKER_HOST_SSH_SIG }} > ~/.ssh/known_hosts
|
2021-02-06 02:04:28 +08:00
|
|
|
cd docker/deployment
|
2021-02-06 16:39:19 +08:00
|
|
|
echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
|
2021-02-06 02:04:28 +08:00
|
|
|
docker-compose build
|
2021-02-06 16:39:19 +08:00
|
|
|
docker-compose push
|
2022-06-19 07:00:21 +08:00
|
|
|
DOCKER_HOST="${{ secrets.DOCKER_HOST }}" docker stack deploy --with-registry-auth --compose-file=docker-compose.yml hangar
|