This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
test ci #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Rivet | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
prepare: | |
name: Prepare | |
runs-on: ubuntu-20.04 | |
outputs: | |
branch_name: ${{ steps.derive_names.outputs.branch_name }} | |
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=branch_name::$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 | tail -n1 | 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 | tail -n1 | 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 "${{ needs.prepare.outputs.branch_name }}" || 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 }}"' | |