Skip to content

Commit

Permalink
add wf battleship-zk (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Magorsky authored Jun 26, 2024
1 parent f79f7c4 commit cb3ae49
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/Release-DeployBattleshipZk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Release - Deploy BattleShips Zk

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
ENVIRONMENT: prod
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBECTL_VERSION: 'v1.22.17'
KUBE_NAMESPACE: gear-dapps
KUBE_DEPLOYMENT_PREFIX: battleship-zk
REGISTRY: ghcr.io/${{ github.repository }}

jobs:
prepair:
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.image.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get branch
id: branch
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Get short SHA
id: sha
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_ENV
- name: Set IMAGE_NAME
id: image
run: |
image_name=${{ env.REGISTRY }}-${{ env.KUBE_DEPLOYMENT_PREFIX }}:${{ env.branch_name }}-${{ env.sha_short }}
echo "image_name=$image_name" >> $GITHUB_OUTPUT
build-and-push-image:
needs: [prepair]
runs-on: ubuntu-latest
environment: prod
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the github container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
file: frontend/apps/battleship-zk/Dockerfile
push: true
tags: ${{ needs.prepair.outputs.image_name }}
build-args: |
VITE_NODE_ADDRESS=${{ secrets.VITE_NODE_ADDRESS }}
VITE_CONTRACT_ADDRESS=${{ secrets.VITE_CONTRACT_ADDRESS_BATTLE }}
VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN_BATTLE }}
VITE_GASLESS_BACKEND_ADDRESS=${{ secrets.VITE_GASLESS_BACKEND_ADDRESS }}
VITE_GTM_ID=${{ secrets.VITE_GTM_ID_BATTLESHIP }}
deploy-to-k8s:
needs: [prepair, build-and-push-image]
runs-on: ubuntu-latest
environment: prod
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Update deployment image
uses: kodermax/kubectl-aws-eks@main
with:
args: |
set image deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }}=${{ needs.prepair.outputs.image_name }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Restart deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout restart deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Check deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout status deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
--timeout=240s \
-n ${{ env.KUBE_NAMESPACE }}
116 changes: 116 additions & 0 deletions .github/workflows/STG-DeployBattleshipZk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Staging - Deploy BattleShips Zk

on:
workflow_dispatch:
push:
branches: ['master', 'main']
paths:
- frontend/apps/battleship-zk/**
- frontend/packages/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
ENVIRONMENT: stg
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBECTL_VERSION: 'v1.22.17'
KUBE_NAMESPACE: gear-dapps
KUBE_DEPLOYMENT_PREFIX: battleship-zk
REGISTRY: ghcr.io/${{ github.repository }}

jobs:
prepair:
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.image.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get branch
id: branch
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Get short SHA
id: sha
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_ENV
- name: Set IMAGE_NAME
id: image
run: |
image_name=${{ env.REGISTRY }}-${{ env.KUBE_DEPLOYMENT_PREFIX }}:${{ env.branch_name }}-${{ env.sha_short }}
echo "image_name=$image_name" >> $GITHUB_OUTPUT
build-and-push-image:
needs: [prepair]
runs-on: ubuntu-latest
environment: stg
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the github container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
file: frontend/apps/battleship-zk/Dockerfile
push: true
tags: ${{ needs.prepair.outputs.image_name }}
build-args: |
VITE_NODE_ADDRESS=${{ secrets.VITE_NODE_ADDRESS }}
VITE_CONTRACT_ADDRESS=${{ secrets.VITE_CONTRACT_ADDRESS_BATTLE }}
VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN_BATTLE }}
VITE_GASLESS_BACKEND_ADDRESS=${{ secrets.VITE_GASLESS_BACKEND_ADDRESS }}
deploy-to-k8s:
needs: [prepair, build-and-push-image]
runs-on: ubuntu-latest
environment: stg
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Update deployment image
uses: kodermax/kubectl-aws-eks@main
with:
args: |
set image deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }}=${{ needs.prepair.outputs.image_name }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Restart deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout restart deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Check deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout status deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
--timeout=240s \
-n ${{ env.KUBE_NAMESPACE }}

0 comments on commit cb3ae49

Please sign in to comment.