From 8bd30e86b2de1cfaafcea95bb479d20d2c6db463 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Mon, 2 Dec 2024 15:21:10 +1100 Subject: [PATCH 1/4] chore: move pipeline to github actions --- .github/mainnet-beta.yml | 67 ++++++++++++++++++++++++++++++++++++++++ .github/master.yml | 67 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/mainnet-beta.yml create mode 100644 .github/master.yml diff --git a/.github/mainnet-beta.yml b/.github/mainnet-beta.yml new file mode 100644 index 0000000..dc130f9 --- /dev/null +++ b/.github/mainnet-beta.yml @@ -0,0 +1,67 @@ +name: Build Image And Deploy + +on: + push: + branches: [mainnet-beta] + +jobs: + build: + runs-on: ubicloud + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_PROD }} + aws-region: ${{ secrets.EKS_PROD_REGION }} + + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Docker build + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: solana-actions-server + IMAGE_TAG: ${{ github.sha }} + BRANCH_NAME: ${{ github.ref_name }} + run: | + docker build \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME \ + -f ./Dockerfile \ + . + + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME + + deploy: + runs-on: ubicloud + needs: [build] + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_PROD }} + aws-region: ${{ secrets.EKS_PROD_REGION }} + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + with: + version: 'v1.30.0' + + - name: Configure AWS EKS Credentials + run: aws eks update-kubeconfig --name ${{ secrets.EKS_PROD_CLUSTER_NAME }} --region ${{ secrets.EKS_PROD_REGION }} --role-arn ${{ secrets.EKS_PROD_DEPLOY_ROLE }} + + - name: Restart deployment + env: + BRANCH_NAME: ${{ github.ref_name }} + run: | + kubectl rollout restart -n $BRANCH_NAME deployment/solana-actions-server-app \ No newline at end of file diff --git a/.github/master.yml b/.github/master.yml new file mode 100644 index 0000000..269d743 --- /dev/null +++ b/.github/master.yml @@ -0,0 +1,67 @@ +name: Build Image And Deploy + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubicloud + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }} + aws-region: ${{ secrets.EKS_NON_PROD_REGION }} + + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Docker build + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: solana-actions-server + IMAGE_TAG: ${{ github.sha }} + BRANCH_NAME: ${{ github.ref_name }} + run: | + docker build \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME \ + -f ./Dockerfile \ + . + + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest-$BRANCH_NAME + + deploy: + runs-on: ubicloud + needs: [build] + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }} + aws-region: ${{ secrets.EKS_NON_PROD_REGION }} + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + with: + version: 'v1.30.0' + + - name: Configure AWS EKS Credentials + run: aws eks update-kubeconfig --name ${{ secrets.EKS_NON_PROD_CLUSTER_NAME }} --region ${{ secrets.EKS_NON_PROD_REGION }} --role-arn ${{ secrets.EKS_NON_PROD_DEPLOY_ROLE }} + + - name: Restart deployment + env: + BRANCH_NAME: ${{ github.ref_name }} + run: | + kubectl rollout restart -n $BRANCH_NAME deployment/solana-actions-server-app \ No newline at end of file From 7f8f17d945ff53f530ecf2c46b2f100a6c9210e3 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Mon, 2 Dec 2024 15:23:25 +1100 Subject: [PATCH 2/4] chore: test GH build --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index d8b8eba..3dbd26c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM public.ecr.aws/bitnami/node:18 ENV NODE_ENV=production RUN npm install -g typescript +# test new build + WORKDIR /app COPY . . RUN yarn From b0ccca84b3804e548a9e8f026c6f30aa1e06341a Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Mon, 2 Dec 2024 15:24:58 +1100 Subject: [PATCH 3/4] fix: move workflows to correct folder --- .github/{ => workflows}/mainnet-beta.yml | 0 .github/{ => workflows}/master.yml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/mainnet-beta.yml (100%) rename .github/{ => workflows}/master.yml (100%) diff --git a/.github/mainnet-beta.yml b/.github/workflows/mainnet-beta.yml similarity index 100% rename from .github/mainnet-beta.yml rename to .github/workflows/mainnet-beta.yml diff --git a/.github/master.yml b/.github/workflows/master.yml similarity index 100% rename from .github/master.yml rename to .github/workflows/master.yml From 4f3e110a99e80d279456f43c60f5cf8f9372b665 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Tue, 3 Dec 2024 11:46:26 +1100 Subject: [PATCH 4/4] chore: test deploy --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3dbd26c..d8b8eba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM public.ecr.aws/bitnami/node:18 ENV NODE_ENV=production RUN npm install -g typescript -# test new build - WORKDIR /app COPY . . RUN yarn