diff --git a/.github/workflows/server2.yml b/.github/workflows/server2.yml new file mode 100644 index 00000000000..0a524f3d136 --- /dev/null +++ b/.github/workflows/server2.yml @@ -0,0 +1,139 @@ +name: Build server + +on: + push: + paths: + - '.github/workflows/server.yml' + - 'app/**' + - 'conf/**' + - 'modules/**' + - 'project/**' + - 'translation/**' + - 'build.sbt' + - 'lila.sh' + - 'conf/application.conf.default' + - '.sbtopts.default' + branches-ignore: + - 'l10n_master' + pull_request: + paths: + - '.github/workflows/server.yml' + - 'app/**' + - 'conf/**' + - 'modules/**' + - 'project/**' + - 'translation/source/**' + - 'build.sbt' + - 'lila.sh' + - 'conf/application.conf.default' + - '.sbtopts.default' + workflow_dispatch: + +env: + SBT_OPTS: '-Xmx2048M' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [21] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: temurin + java-version: ${{ matrix.java-version }} + cache: sbt + - name: Setup sbt + uses: sbt/setup-sbt@93e926cbdb4a428e41b4ef754124ec82925ffdc2 # v1.1.23 + - run: TZ=UTC git log -1 --date=iso-strict-local --pretty='format:app.version.commit = "%H"%napp.version.date = "%ad"%napp.version.message = """%s"""%n' | tee conf/version.conf + - run: ./lila.sh -Depoll=true "test;stage" + - run: cp LICENSE COPYING.md README.md target/universal/stage && git log -n 1 --pretty=oneline > target/universal/stage/commit.txt + - run: cd target/universal/stage && tar --zstd -cvpf ../../../lila-3.0.tar.zst . && cd - + env: + ZSTD_LEVEL: 1 # most files are already zipped + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: ${{ matrix.java-version == 21 }} + with: + name: lila-server + path: lila-3.0.tar.zst + compression-level: 0 # already compressed + + docker: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch || github.event_name == 'workflow_dispatch' + concurrency: + group: docker-build-publish + cancel-in-progress: true + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: lila-server + + - name: Extract artifact + run: | + mkdir -p lila + tar --zstd -xvf *.tar.zst -C lila + + - name: Copy default conf + run: | + cp -r conf lila + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + with: + images: ghcr.io/${{ github.repository }}-server + tags: | + type=ref,event=branch + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + context: . + file: .github/workflows/docker/lila.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy: + if: github.repository == 'lichess-org/lila' && github.ref_name == github.event.repository.default_branch + needs: docker + runs-on: ubuntu-latest + steps: + - name: deploy to preview site + env: + DEPLOY_WEBHOOK_URL: ${{ secrets.DEPLOY_PREVIEW_SERVER_URL }} + run: curl -X POST $DEPLOY_WEBHOOK_URL + + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: temurin + java-version: 21 + cache: sbt + - name: Setup sbt + uses: sbt/setup-sbt@93e926cbdb4a428e41b4ef754124ec82925ffdc2 # v1.1.23 + + - name: Check Formatting + run: sbt scalafmtCheckAll