Skip to content

Commit

Permalink
Merge pull request #18 from metaDAOproject/staging
Browse files Browse the repository at this point in the history
Go To Production...
  • Loading branch information
LukasDeco authored Jun 27, 2024
2 parents 26000ef + 662bbaa commit 0dfd930
Show file tree
Hide file tree
Showing 42 changed files with 2,946 additions and 561 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Rust

on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
54 changes: 54 additions & 0 deletions .github/workflows/build-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PRODUCTION -- Build & Push Docker Image
on:
push:
branches: [main]
paths:
- "**"

jobs:
build_and_push:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: "true"

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: lukasdeco/indexer

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: themetadao/asset-watcher:main
labels: ${{ steps.meta.outputs.labels }}

# redeploy_app:
# name: Redeploy app on Railway
# needs: build_and_push
# runs-on: ubuntu-latest
# steps:
# - name: Call Redeploy API
# env:
# RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# run: |
# echo railway toke: $RAILWAY_TOKEN
# echo "Authorization: Bearer ${RAILWAY_TOKEN}"
# curl https://backboard.railway.app/graphql/v2 \
# -X POST \
# -H "Authorization: Bearer ${RAILWAY_TOKEN}" \
# -H "Content-Type: application/json" \
# --data '{"query": "mutation serviceInstanceDeploy($serviceId: String!, $environmentId: String!) {\n serviceInstanceDeploy(serviceId: $serviceId, environmentId: $environmentId)\n}\n", "variables": { "environmentId": "0942e3fe-8ec3-49b4-b8fb-26eb10b6e08f", "serviceId": "783719dc-3c30-437d-a3a9-b1aeb1d5c487" } }'
54 changes: 54 additions & 0 deletions .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: STAGING -- Build & Push Docker Image
on:
push:
branches: [staging]
paths:
- "**"

jobs:
build_and_push:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: "true"

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: lukasdeco/indexer

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: themetadao/asset-watcher:staging
labels: ${{ steps.meta.outputs.labels }}

redeploy_app:
name: Redeploy app on Railway
needs: build_and_push
runs-on: ubuntu-latest
steps:
- name: Call Redeploy API
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
run: |
echo railway toke: $RAILWAY_TOKEN
echo "Authorization: Bearer ${RAILWAY_TOKEN}"
curl https://backboard.railway.app/graphql/v2 \
-X POST \
-H "Authorization: Bearer ${RAILWAY_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"query": "mutation serviceInstanceDeploy($serviceId: String!, $environmentId: String!) {\n serviceInstanceDeploy(serviceId: $serviceId, environmentId: $environmentId)\n}\n", "variables": { "environmentId": "4015588d-3c82-4413-9484-314539aecd39", "serviceId": "c1221eaa-e011-4ed7-9bbb-5597692f5532" } }'
Loading

0 comments on commit 0dfd930

Please sign in to comment.