From 5610d705bf90e1bcc2ee534d79fc8968bccbc9b8 Mon Sep 17 00:00:00 2001 From: shuse2 Date: Tue, 30 Jan 2024 10:37:15 +0100 Subject: [PATCH] feat: add deployment scripts --- .github/workflows/deployment.yaml | 58 +++++++++++++++++++++++++++++++ Dockerfile | 10 ++++++ docusaurus.config.js | 5 +-- 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deployment.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml new file mode 100644 index 000000000..9057a71a5 --- /dev/null +++ b/.github/workflows/deployment.yaml @@ -0,0 +1,58 @@ +# https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service +name: Deployment + +on: + push: + branches: + - main + - 32-add-deployment + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + environment: ${{ github.ref_name }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc + with: + task-definition: ${{ env.ECS_TASK_DEFINITION }} + container-name: ${{ env.CONTAINER_NAME }} + image: ${{ steps.build-image.outputs.image }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: ${{ env.ECS_SERVICE }} + cluster: ${{ env.ECS_CLUSTER }} + wait-for-service-stability: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2e741d04d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:lts + +WORKDIR /app/website + +EXPOSE 3000 35729 +COPY . . +RUN yarn install +RUN yarn build + +CMD ["yarn", "serve"] diff --git a/docusaurus.config.js b/docusaurus.config.js index d7aaa5204..84968c47d 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -5,6 +5,7 @@ // See: https://docusaurus.io/docs/api/docusaurus-config import { themes as prismThemes } from 'prism-react-renderer'; +import * as process from 'process'; /** @type {import('@docusaurus/types').Config} */ const config = { @@ -13,10 +14,10 @@ const config = { favicon: 'img/favicon.png', // Set the production url of your site here - url: 'https://docs.lisk.com', + url: process.env.LISK_DOC_URL ?? 'https://documentation.lisk.com', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '/lisk-documentation/', + baseUrl: process.env.LISK_DOC_BASE_URL ?? '/', // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these.