From 8c9cd1e31a8f5865cadba6fee6d1cda9f468e05f Mon Sep 17 00:00:00 2001 From: Ray <22254748+rayokamoto@users.noreply.github.com> Date: Mon, 27 May 2024 23:07:24 +0930 Subject: [PATCH] ci: make workflows for dev and clean up prod workflow --- .github/workflows/build_and_test.yml | 46 ------------------- .github/workflows/ci-dev-pr.yml | 33 +++++++++++++ .github/workflows/ci-dev.yml | 11 +++++ .../workflows/{deploy.yml => production.yml} | 12 ++--- 4 files changed, 50 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/build_and_test.yml create mode 100644 .github/workflows/ci-dev-pr.yml create mode 100644 .github/workflows/ci-dev.yml rename .github/workflows/{deploy.yml => production.yml} (92%) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml deleted file mode 100644 index 54bd9990..00000000 --- a/.github/workflows/build_and_test.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build and Test -on: - pull_request: - branches: - - '*' - push: - branches: [main, ci] - -jobs: - build: - name: Run build - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v3 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build - run: pnpm run build diff --git a/.github/workflows/ci-dev-pr.yml b/.github/workflows/ci-dev-pr.yml new file mode 100644 index 00000000..c5857399 --- /dev/null +++ b/.github/workflows/ci-dev-pr.yml @@ -0,0 +1,33 @@ +name: Development - Pull Request +on: + pull_request: + branches: + - '**' + +jobs: + lint-format: + name: Linting and Formatting Checks + uses: ./.github/workflows/lint-and-format.yml + + build: + needs: lint-format + name: Build + runs-on: ubuntu-latest + environment: Development + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Docker container + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + REDIS_URI: ${{ secrets.REDIS_URI }} + NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }} + NEXT_PUBLIC_DRIVE_LINK: ${{ secrets.NEXT_PUBLIC_DRIVE_LINK }} + run: | + docker buildx build \ + --secret id=DATABASE_URL \ + --secret id=REDIS_URI \ + --secret id=NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \ + --secret id=NEXT_PUBLIC_DRIVE_LINK \ + --file=Dockerfile -t csclub-website . diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml new file mode 100644 index 00000000..63f65f71 --- /dev/null +++ b/.github/workflows/ci-dev.yml @@ -0,0 +1,11 @@ +name: Development +on: + push: + branches: + - '**' + - '!main' + +jobs: + lint-format: + name: Linting and Formatting Checks + uses: ./.github/workflows/lint-and-format.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/production.yml similarity index 92% rename from .github/workflows/deploy.yml rename to .github/workflows/production.yml index dfcb320f..8d9b892d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/production.yml @@ -1,19 +1,19 @@ -name: Deploy +name: Production on: push: - branches: [main, ci-aws] # ci-aws is temporary + branches: [main] env: AWS_REGION: ap-southeast-2 jobs: - # lint-format: - # name: Linting and Formatting Checks - # uses: ./.github/workflows/lint-and-format.yml + lint-format: + name: Linting and Formatting Checks + uses: ./.github/workflows/lint-and-format.yml build: - # needs: lint-format + needs: lint-format name: Build runs-on: [self-hosted, ARM64] # Since deployment is on arm64 environment: Production