#Tabs not spaces, you moron :) name: CI for netris:server on: pull_request: paths: - "server.Dockerfile" - ".scripts/**" - ".github/workflows/server.yml" schedule: - cron: 0 0 * * * # At the end of everyday push: branches: [main] paths: - "server.Dockerfile" - ".scripts/**" - ".github/workflows/server.yml" tags: - v*.*.* release: types: [created] env: REGISTRY: ghcr.io IMAGE_NAME: wanjohiryan/netris BASE_TAG_PREFIX: server concurrency: group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: build-cargo: defaults: run: working-directory: moq-server runs-on: ubuntu-20.04 steps: - name: Checkout repository uses: actions/checkout@v3 with: submodules: recursive - name: Install Rust id: toolchain uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-linux-gnu toolchain: stable components: clippy, rustfmt - name: Cache Rust Dependencies uses: Swatinem/rust-cache@v2 with: save-if: false prefix-key: 'v0-rust-deps' shared-key: x86_64-unknown-linux-gnu - name: Cargo build run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ./moq-pub/Cargo.toml --release - name: Copy and rename artifacts (Linux) run: | cp target/x86_64-unknown-linux-gnu/release/moq-pub ./warp - name: Publish artifacts uses: actions/upload-artifact@v3 with: name: warp path: ./moq-server/warp if-no-files-found: error retention-days: 5 build-docker-pr: name: Build image on pr needs: - build-cargo runs-on: ubuntu-latest if: ${{ github.event_name == 'pull_request' }} steps: - name: Checkout repo uses: actions/checkout@v4 - name: Download go binary uses: actions/download-artifact@v3 with: name: warp path: ./ - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build Docker image uses: docker/build-push-action@v5 with: file: server.Dockerfile context: ./ push: false load: true tags: netris:server build-docker-main: name: Build image on merge to main if: ${{github.ref == 'refs/heads/main'}} runs-on: ubuntu-latest needs: - build-cargo permissions: contents: read packages: write steps: - name: Checkout repo uses: actions/checkout@v4 - name: Download warp uses: actions/download-artifact@v3 with: name: warp path: ./ - name: Log into registry ${{ env.REGISTRY }} uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Container metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ env.BASE_TAG_PREFIX }} # #tag on release, and a nightly build for 'dev' tags: | type=raw,value=nightly,enable={{is_default_branch}} type=ref,event=tag type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - name: Build Docker image uses: docker/build-push-action@v5 with: file: server.Dockerfile context: ./ push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}