From 7a34c7361769ce119646b30df79312ff5fe6ae16 Mon Sep 17 00:00:00 2001 From: Hiep Mai Date: Mon, 5 Aug 2024 15:24:17 +0700 Subject: [PATCH] feat: Add github actions --- .github/workflows/ci.yml | 10 ++++++++++ .github/workflows/publish.yaml | 35 ++++++++++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++--------- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..a2ff27f6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,10 @@ +name: ci + +on: + pull_request: + branches: + - '**' + +jobs: + test: + uses: babylonlabs-io/.github/.github/workflows/reusable_node_lint_test.yml@hiep/add-nodejs-workflows \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..23abf95d --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,35 @@ +name: docker_publish + +on: + push: + branches: + - 'hiep/add-github-actions' + # - 'main' + # - 'dev' + # tags: + # - '*' + +jobs: + test: + uses: babylonlabs-io/.github/.github/workflows/reusable_node_lint_test.yml@hiep/add-nodejs-workflows + + docker_pipeline: + needs: ["test"] + uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@hiep/add-nodejs-workflows + secrets: inherit + strategy: + matrix: + environment: [devnet, staging] + with: + publish: true + environment: ${{ matrix.environment }} + buildArgs: | + NEXT_PUBLIC_MEMPOOL_API=${{ vars.NEXT_PUBLIC_MEMPOOL_API }} + NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} + NEXT_PUBLIC_NETWORK=${{ vars.NEXT_PUBLIC_NETWORK }} + NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=${{ vars.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES }} + repoName: "simple-staking-${{ matrix.environment }}" + + + + diff --git a/Dockerfile b/Dockerfile index 08973a98..086a567b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,15 +15,20 @@ COPY tailwind.config.ts . COPY postcss.config.js . COPY docker-entrypoint.sh . -# We replace NEXT_PUBLIC_* variables here with placeholders -# as next.js automatically replaces those during building -# Later the docker-entrypoint.sh script finds such variables and replaces them -# with the docker environment variables we have set -RUN NEXT_PUBLIC_MEMPOOL_API=APP_NEXT_PUBLIC_MEMPOOL_API \ - NEXT_PUBLIC_API_URL=APP_NEXT_PUBLIC_API_URL \ - NEXT_PUBLIC_NETWORK=APP_NEXT_PUBLIC_NETWORK \ - NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=APP_NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES \ - npm run build + +ARG NEXT_PUBLIC_MEMPOOL_API +ENV NEXT_PUBLIC_MEMPOOL_API=${NEXT_PUBLIC_MEMPOOL_API} + +ARG NEXT_PUBLIC_API_URL +ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} + +ARG NEXT_PUBLIC_NETWORK +ENV NEXT_PUBLIC_NETWORK=${NEXT_PUBLIC_NETWORK} + +ARG NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES +ENV NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=${NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES} + +RUN npm run build # Step 2. Production image, copy all the files and run next FROM node:22-alpine3.19 AS runner