Skip to content

Commit

Permalink
ci: deploy to production using tags
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloCastellano committed Mar 13, 2024
1 parent 1d25c61 commit 213d2ba
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 17 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Continuous Integration (build, test, docker, deploy)

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
push:
branches: ["master"]
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -77,18 +79,3 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy_staging:
if: github.ref_name == 'master'
name: Deploy blobscan api (staging)
runs-on: ubuntu-latest
environment: staging
needs: docker
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh
72 changes: 72 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy production

on:
workflow_run:
workflows: ["CI"]
types:
- completed

jobs:
deploy_sepolia:
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/')
name: Deploy Blobscan indexer (sepolia)
runs-on: ubuntu-latest
environment: sepolia
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh

deploy_holesky:
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/')
name: Deploy Blobscan indexer (holesky)
runs-on: ubuntu-latest
environment: holesky
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh

deploy_gnosis:
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/')
name: Deploy Blobscan indexer (gnosis)
runs-on: ubuntu-latest
environment: gnosis
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh

deploy_mainnet:
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/')
name: Deploy Blobscan indexer (mainnet)
runs-on: ubuntu-latest
environment: mainnet
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh
23 changes: 23 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy staging

on:
workflow_run:
workflows: ["CI"]
branches: ["master"]
types:
- completed

jobs:
deploy_staging:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Deploy Blobscan indexer (staging)
runs-on: ubuntu-latest
environment: staging
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan-indexer.rs.sh

0 comments on commit 213d2ba

Please sign in to comment.