Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

test ci

test ci #10

Workflow file for this run

name: Deploy to Rivet
on:
push:
branches:
- '**'
jobs:
prepare:
name: Prepare
runs-on: ubuntu-20.04
outputs:
ns_name_id: ${{ steps.derive_names.outputs.ns_name_id }}
version_name: ${{ steps.derive_names.outputs.version_name }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Generate ns_name and version_name
id: derive_names
run: |
branch_name=${GITHUB_REF#refs/heads/}
# Max namespace length is 16 characters
ns_name_id=$(echo $branch_name | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]\+/-/g' | cut -c 1-16)
short_hash=$(git rev-parse --short HEAD)
version_name="${short_hash} (${branch_name})"
echo "::set-output name=ns_name_id::$ns_name_id"
echo "::set-output name=version_name::$version_name"
build_job_matchmaker:
name: Build Docker Image (Dockerfile)
needs: prepare
runs-on: ubuntu-20.04
outputs:
image_id: ${{ steps.build_image.outputs.image_id }}
env:
RIVET_API_ENDPOINT: "https://api.staging2.gameinc.io"
RIVET_TOKEN: ${{ secrets.RIVET_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rivet CLI
run: |
export RIVET_CLI_VERSION="v0.3.1"
curl -fsSL https://raw.githubusercontent.com/rivet-gg/cli/main/install/unix.sh | sh
- name: Build Docker Image
id: build_image
run: |
output=$(rivet image build-push --format json --name '${{ needs.prepare.outputs.ns_name_id }}' --dockerfile 'Dockerfile')
echo "::set-output name=image_id::$(echo $output | jq -r '.image_id')"
build_cdn:
name: Build CDN Site
needs: prepare
runs-on: ubuntu-20.04
outputs:
site_id: ${{ steps.build_cdn.outputs.site_id }}
env:
RIVET_API_ENDPOINT: "https://api.staging2.gameinc.io"
RIVET_TOKEN: ${{ secrets.RIVET_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rivet CLI
run: |
export RIVET_CLI_VERSION="v0.3.1"
curl -fsSL https://raw.githubusercontent.com/rivet-gg/cli/main/install/unix.sh | sh
- name: Build CDN
id: build_cdn
run: |
output=$(rivet site build-push --format json --name '${{ needs.prepare.outputs.ns_name_id }}' --command 'yarn install && yarn run build' --path 'dist')
echo "::set-output name=site_id::$(echo $output | jq -r '.site_id')"
deploy:
name: Deploy
needs: [prepare, build_job_matchmaker, build_cdn]
runs-on: ubuntu-20.04
env:
RIVET_API_ENDPOINT: "https://api.staging2.gameinc.io"
RIVET_TOKEN: ${{ secrets.RIVET_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rivet CLI
run: |
export RIVET_CLI_VERSION="v0.3.1"
curl -fsSL https://raw.githubusercontent.com/rivet-gg/cli/main/install/unix.sh | sh
- name: Create Namespace
run: |
# Ignore error if namespace already exists
rivet namespace create --id "${{ needs.prepare.outputs.ns_name_id }}" --name "$(git rev-parse --abbrev-ref HEAD)" || true
- name: Deploy Version
run: |
rivet deploy --namespace '${{ needs.prepare.outputs.ns_name_id }}' --name '${{ needs.prepare.outputs.version_name }}' --override 'matchmaker.docker.image_id="${{ needs.build_job_matchmaker.outputs.image_id }}"' --override 'cdn.site_id="${{ needs.build_cdn.outputs.site_id }}"'