Hangar/.github/workflows/deploy.yml

109 lines
3.3 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
- 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
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)
- 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!
proxyHost: "http://hangar_new_backend:8080"
authHost: "https://hangar-auth.benndorf.dev"
host: "0.0.0.0"
PUBLIC_HOST: "https://hangar.benndorf.dev"
2021-02-06 02:07:58 +08:00
run: (cd frontend && yarn build)
- 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 }}
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 }}
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: |
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_new