Skip to content

Update railway arguments. #210

Update railway arguments.

Update railway arguments. #210

Workflow file for this run

name: CI
on:
push:
release:
types: [published]
workflow_dispatch:
inputs:
upload:
description: 'Upload the docker container'
required: false
default: false
type: boolean
redeploy:
description: 'Redeploy the container on pkg.toit.io'
required: false
default: false
type: boolean
redeploy-dev:
description: 'Redeploy the container on pkg-dev.toit.io'
required: false
default: false
type: boolean
env:
DOCKER_NAME: tpkg_registry
RAILWAY_PROJECT_ID: 6580ada5-829d-4c2a-8b84-0096bd87b421
RAILWAY_SERVICE_ID: d9ab2b13-9265-4757-97eb-282ac85f15fc
RAILWAY_DEV_SERVICE_ID: d22a4836-8f41-4d8b-b26c-bc16546e0738
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Fetch the whole history.
# Use Go 1.17
- name: Switch to Go 1.17
uses: actions/setup-go@v5
with:
go-version: '^1.17.0'
- name: Go dependencies
run: |
make go_dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- name: Build protobuf
run: |
make protobuf
- name: Build binary
run: |
make registry
- name: Test
run: |
make test
- name: Fetch dependencies
run: |
make image-dependencies
- name: Print known-hosts
run: |
ssh-keyscan github.com >> known_hosts
echo "You can use the following known_hosts file to add to your secrets"
cat known_hosts
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_NAME }}
# Generate Docker tags based on the following events/attributes.
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Print configuration
run: |
echo "DOCKER_NAME=${{ env.DOCKER_NAME }}"
echo "TAGS=${{ steps.meta.outputs.tags }}"
echo "LABELS=${{ steps.meta.outputs.labels }}"
- name: Login to GHCR
if: |
github.event.inputs.upload == 'true' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{
github.event.inputs.upload == 'true' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
- name: Install Railway
if: |
github.event.inputs.redeploy == 'true' ||
github.event.inputs.redeploy-dev == 'true' ||
github.event_name == 'release' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
run: npm i -g @railway/cli
- name: Deploy pkg-dev.toit.io
if: |
github.event.inputs.redeploy-dev == 'true' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# pkg-dev.toit.io is set up as follows:
# - Source image: ghcr.io/toitware/tpkg_registry:main
# - Variables:
# REGISTRY_BRANCH="main"
# REGISTRY_SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY----- ... -----END OPENSSH PRIVATE KEY"
# REGISTRY_SSH_KEY_FILE="/secrets/ssh-key"
# REGISTRY_URL="github.com/toitware/registry"
run: |
railway link --project $RAILWAY_PROJECT_ID --service $RAILWAY_DEV_SERVICE_ID
railway redeploy -y
- name: Deploy pkg.toit.io
if: github.event.inputs.redeploy == 'true' || github.event_name == 'release'
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# pkg.toit.io is set up as follows:
# - Source image: ghcr.io/toitware/tpkg_registry:latest
# - Variables:
# REGISTRY_BRANCH="main"
# REGISTRY_SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY----- ... -----END OPENSSH PRIVATE KEY"
# REGISTRY_SSH_KEY_FILE="/secrets/ssh-key"
# REGISTRY_URL="github.com/toitware/registry"
run: |
railway link --project $RAILWAY_PROJECT_ID --service $RAILWAY_SERVICE_ID
railway redeploy -y