From 4b0e07702a07cf0df476fca0785cc211debb9542 Mon Sep 17 00:00:00 2001 From: sergey filyanin Date: Fri, 29 Nov 2024 12:02:45 +0100 Subject: [PATCH] Create docker.yml --- .github/workflows/docker.yml | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..90d7145f11 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,74 @@ +name: Deploy Staking dashboard + +on: + push: + branches: ['main', '*'] # Отслеживаем main и любые другие ветки + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + 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 }} + KUBE_NAMESPACE: gear-dapps + +jobs: + + build-and-push-dashboard-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the github container registry + uses: docker/login-action@master + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Docker tag + id: set-docker-tag + run: | + if [ "${GITHUB_REF##*/}" == "main" ]; then + echo "tag=latest" >> $GITHUB_ENV + else + echo "tag=qa" >> $GITHUB_ENV + fi + + - name: Build and push Dashboard image + uses: docker/build-push-action@master + with: + file: Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} + + deploy-dashboard-k8s: + needs: [build-and-push-dashboard-image] + runs-on: ubuntu-latest + + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + 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: Deploy to k8s + uses: sergeyfilyanin/kubectl-aws-eks@master + with: + args: > + rollout restart deployment + ${{ github.ref == 'refs/heads/main' && 'cb-dashboard' || 'cb-dashboard-stg' }} + -n $KUBE_NAMESPACE