Skip to content

Update README.md

Update README.md #26

Workflow file for this run

name: Deploy
## workflow will need manual trigger from actions page
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
name: Build
uses: ./.github/workflows/build.yaml
permissions:
contents: read
id-token: write
packages: write
deploy:
name: Deploy Railway
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Railway CLI
run: |
bash <(curl -fsSL cli.new)
- name: Install Redis-CLI
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: 7
auto-start: "false"
- name: Install Postgresql client-only
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
- name: Get Last Commit Short SHA
id: commit_data
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Cardinal - Shutdown Previous Deployment
working-directory: world-engine/cardinal
run: |
## Get Cardinal Latest Deployment ID
DEPLOYMENT_ID=$(curl --location 'https://backboard.railway.app/graphql/v2' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"query deployments($projectId: String!, $environmentId: String!, $serviceId: String!) {\n deployments(\n first: 1\n input: {\n projectId: $projectId\n environmentId: $environmentId\n serviceId: $serviceId\n }\n ) {\n edges {\n node {\n id\n staticUrl\n }\n }\n }\n}",
"variables":{"projectId":"${{ vars.RAILWAY_PROJECT_ID }}","environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","serviceId":"${{ vars.RAILWAY_CARDINAL_SERVICE_ID }}"}}' | jq -r '.data.deployments.edges[].node.id')
## Remove Deployment
curl --location 'https://backboard.railway.app/graphql/v2' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation deploymentRemove($id: String!) {\n deploymentRemove(id: $id)\n}","variables":{"id":"'${DEPLOYMENT_ID}'"}}'
- name: Clear Up Redis
run: |
sleep 10
redis-cli -h ${{ secrets.PROD_REDIS_HOST }} -p ${{ secrets.PROD_REDIS_PORT }} <<EOF
AUTH ${{ secrets.PROD_REDIS_PASSWORD }}
FLUSHALL
keys *
EOF
- name: Cardinal - Up New Deployment
env:
RAILWAY_TOKEN: ${{ secrets.PROD_RAILWAY_TOKEN }}
run: |
## remove prev docker image
curl --location 'https://backboard.railway.app/graphql/internal?q=stageEnvironmentChanges' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation stageEnvironmentChanges($environmentId: String!, $payload: EnvironmentConfig!) {\n environmentStageChanges(environmentId: $environmentId, input: $payload) {\n id\n }\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","payload":{"services":{"${{ vars.RAILWAY_CARDINAL_SERVICE_ID }}":{"source":{"image":null}}}}}}'
sleep 5
## commit changes
curl --location 'https://backboard.railway.app/graphql/internal?q=environmentPatchCommitStaged' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation environmentPatchCommitStaged($environmentId: String!, $message: String, $skipDeploys: Boolean) {\n environmentPatchCommitStaged(\n environmentId: $environmentId\n commitMessage: $message\n skipDeploys: $skipDeploys\n )\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","skipDeploys":false}}'
sleep 5
## change new docker image
curl --location 'https://backboard.railway.app/graphql/internal?q=stageEnvironmentChanges' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation stageEnvironmentChanges($environmentId: String!, $payload: EnvironmentConfig!) {\n environmentStageChanges(environmentId: $environmentId, input: $payload) {\n id\n }\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","payload":{"services":{"${{ vars.RAILWAY_CARDINAL_SERVICE_ID }}":{"source":{"image":"ghcr.io/franklindao-dev-team/arcanereveal/cardinal:sha-${{ steps.commit_data.outputs.sha_short }}","repo":null,"branch":null,"upstreamUrl":null},"deploy":{"registryCredentials":{"username":"USERNAME","password":"${{ secrets.RAILWAY_GITHUB_REGISTRY_TOKEN }}"}}}}}}}'
sleep 5
## commit changes
curl --location 'https://backboard.railway.app/graphql/internal?q=environmentPatchCommitStaged' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation environmentPatchCommitStaged($environmentId: String!, $message: String, $skipDeploys: Boolean) {\n environmentPatchCommitStaged(\n environmentId: $environmentId\n commitMessage: $message\n skipDeploys: $skipDeploys\n )\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","skipDeploys":false}}'
- name: Godot Client - Up New Deployment
env:
RAILWAY_TOKEN: ${{ secrets.PROD_RAILWAY_TOKEN }}
run: |
## remove prev docker image
curl --location 'https://backboard.railway.app/graphql/internal?q=stageEnvironmentChanges' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation stageEnvironmentChanges($environmentId: String!, $payload: EnvironmentConfig!) {\n environmentStageChanges(environmentId: $environmentId, input: $payload) {\n id\n }\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","payload":{"services":{"${{ vars.RAILWAY_GODOT_SERVICE_ID }}":{"source":{"image":null}}}}}}'
sleep 5
## commit changes
curl --location 'https://backboard.railway.app/graphql/internal?q=environmentPatchCommitStaged' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation environmentPatchCommitStaged($environmentId: String!, $message: String, $skipDeploys: Boolean) {\n environmentPatchCommitStaged(\n environmentId: $environmentId\n commitMessage: $message\n skipDeploys: $skipDeploys\n )\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","skipDeploys":false}}'
sleep 5
## change new docker image
curl --location 'https://backboard.railway.app/graphql/internal?q=stageEnvironmentChanges' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation stageEnvironmentChanges($environmentId: String!, $payload: EnvironmentConfig!) {\n environmentStageChanges(environmentId: $environmentId, input: $payload) {\n id\n }\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","payload":{"services":{"${{ vars.RAILWAY_GODOT_SERVICE_ID }}":{"source":{"image":"ghcr.io/franklindao-dev-team/arcanereveal/godotexport:sha-${{ steps.commit_data.outputs.sha_short }}","repo":null,"branch":null,"upstreamUrl":null},"deploy":{"registryCredentials":{"username":"USERNAME","password":"${{ secrets.RAILWAY_GITHUB_REGISTRY_TOKEN }}"}}}}}}}'
sleep 5
## commit changes
curl --location 'https://backboard.railway.app/graphql/internal?q=environmentPatchCommitStaged' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation environmentPatchCommitStaged($environmentId: String!, $message: String, $skipDeploys: Boolean) {\n environmentPatchCommitStaged(\n environmentId: $environmentId\n commitMessage: $message\n skipDeploys: $skipDeploys\n )\n}","variables":{"environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","skipDeploys":false}}'
- name: Cardinal Healthcheck
run: |
curl -X POST --max-time 10 --retry 20 --retry-delay 5 --retry-max-time 300 ${{ vars.PROD_CARDINAL_HEALTHCHECK }} -d "{}"
- name: Remove Nakama Database (Railway)
run: |
PGPASSWORD=${{ secrets.PROD_RAILWAY_POSTGRES_PASSWORD }} psql -h ${{ secrets.PROD_RAILWAY_POSTGRES_HOST }} -U ${{ secrets.PROD_RAILWAY_POSTGRES_USER }} -p ${{ secrets.PROD_RAILWAY_POSTGRES_PORT }} -d railway -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
- name: Restart Nakama Services (Railway)
run: |
## Get NAKAMA Latest Deployment ID
DEPLOYMENT_ID=$(curl --location 'https://backboard.railway.app/graphql/v2' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"query deployments($projectId: String!, $environmentId: String!, $serviceId: String!) {\n deployments(\n first: 1\n input: {\n projectId: $projectId\n environmentId: $environmentId\n serviceId: $serviceId\n }\n ) {\n edges {\n node {\n id\n staticUrl\n }\n }\n }\n}",
"variables":{"projectId":"${{ vars.RAILWAY_PROJECT_ID }}","environmentId":"${{ vars.PROD_RAILWAY_ENVIRONMENT_ID }}","serviceId":"${{ vars.RAILWAY_NAKAMA_SERVICE_ID }}"}}' | jq -r '.data.deployments.edges[].node.id')
## RESTART Deployment
curl --location 'https://backboard.railway.app/graphql/v2' \
--header 'Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation deploymentRestart($id: String!) {\n deploymentRestart(id: $id)\n}","variables":{"id":"'${DEPLOYMENT_ID}'"}}'