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
|
|
|
|
|
|
|
|
- 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'
|
|
|
|
|
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
|
|
|
|
|
|
|
- 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)
|
|
|
|
|
2021-12-19 18:59:02 +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
|
2021-12-21 20:06:06 +08:00
|
|
|
skip_untranslated_strings: true
|
2021-12-19 18:59:02 +08:00
|
|
|
config: 'crowdin.yml'
|
|
|
|
crowdin_branch_name: master
|
|
|
|
env:
|
|
|
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
|
|
|
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!
|
|
|
|
proxyHost: "http://hangar_new_backend:8080"
|
2021-11-23 14:49:45 +08:00
|
|
|
authHost: "https://hangar-auth.benndorf.dev"
|
2021-03-17 02:12:13 +08:00
|
|
|
host: "0.0.0.0"
|
2021-04-02 20:59:32 +08:00
|
|
|
PUBLIC_HOST: "https://hangar.benndorf.dev"
|
2021-02-06 02:07:58 +08:00
|
|
|
run: (cd frontend && yarn build)
|
|
|
|
|
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 }}
|
|
|
|
|
2021-02-06 02:26:05 +08:00
|
|
|
- name: Docker
|
2021-07-01 02:12:01 +08:00
|
|
|
env:
|
|
|
|
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
2021-07-01 02:34:27 +08:00
|
|
|
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
|
|
|
|
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
|
|
|
|
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
|
|
|
|
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
|
2021-10-17 00:20:06 +08:00
|
|
|
SSO_CLIENT_ID: ${{ secrets.SSO_CLIENT_ID }}
|
2021-07-01 02:12:01 +08:00
|
|
|
SSO_SECRET: ${{ secrets.SSO_SECRET }}
|
|
|
|
API_KEY: ${{ secrets.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
|
2021-03-16 02:37:18 +08:00
|
|
|
DOCKER_HOST="${{ secrets.DOCKER_HOST }}" docker stack deploy --with-registry-auth --compose-file=docker-compose.yml hangar_new
|