Hangar/.github/workflows/deploy.yml

117 lines
3.5 KiB
YAML
Raw Normal View History

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:
- master
concurrency:
group: ${{ github.ref }}
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:
java-version: 17
2021-02-05 23:45:53 +08:00
- name: Set up Node
uses: actions/setup-node@v2
with:
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
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
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
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-02-06 02:07:58 +08:00
- name: Build frontend
env:
CI: true
# 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"
PUBLIC_HOST: "https://hangar.benndorf.dev"
2022-07-29 17:42:38 +08:00
DEBUG: "hangar:*"
run: (cd frontend && pnpm build && cd server && pnpm build)
2022-03-21 20:41:17 +08:00
- name: SSH
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'
with:
ssh-private-key: ${{ secrets.DOCKER_HOST_SSH_KEY }}
# 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
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 }}
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: |
echo ${{ secrets.DOCKER_HOST_SSH_SIG }} > ~/.ssh/known_hosts
2021-02-06 02:04:28 +08:00
cd docker/deployment
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
docker-compose push
DOCKER_HOST="${{ secrets.DOCKER_HOST }}" docker stack deploy --with-registry-auth --compose-file=docker-compose.yml hangar