From 16d96db6237cc803eac6b88b2b1b5135f80de095 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 28 Oct 2024 16:21:33 +0100 Subject: [PATCH] add deploy --- .github/workflows/docker-build-push.yml | 31 ------- .github/workflows/publish_deploy.yml | 104 ++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/publish_deploy.yml diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index ba51d0a..d8a8863 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -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 }} @@ -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 diff --git a/.github/workflows/publish_deploy.yml b/.github/workflows/publish_deploy.yml new file mode 100644 index 0000000..2ea6529 --- /dev/null +++ b/.github/workflows/publish_deploy.yml @@ -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 }}