Skip to content

Commit

Permalink
add deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
alvicsam committed Oct 28, 2024
1 parent 11c8498 commit 16d96db
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 31 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: CI
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -55,31 +52,3 @@ jobs:
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: main
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Build and push Docker image from main
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
104 changes: 104 additions & 0 deletions .github/workflows/publish_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: paritytech/testnet-manager
APP: "testnet-manager"

jobs:
set-variables:
name: Set variables
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Define version
id: version
run: |
export COMMIT_SHA=${{ github.sha }}
export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8}
export REF_NAME=${{ github.ref_name }}
export REF_SLUG=${REF_NAME//\//_}
if [[ ${REF_SLUG} == "main" ]]
then
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
else
echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT
fi
echo "set VERSION=${VERSION}"
docker-publish:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: main
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Build and push Docker image from main
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
deploy-versi:
name: Deploy Versi
runs-on: ubuntu-latest
needs: [set-variables, docker-publish]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "versi-argocd.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-stg"
tag: "${{ env.VERSION }}"
app_name: "${{ env.APP }}"
app_packages: "${{ env.APP }}"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-stg"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}

deploy-westend:
name: Deploy Westend
runs-on: ubuntu-latest
needs: [set-variables, docker-publish]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "westend-argocd.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-stg"
tag: "${{ env.VERSION }}"
app_name: "${{ env.APP }}"
app_packages: "${{ env.APP }}"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-stg"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}

0 comments on commit 16d96db

Please sign in to comment.