diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 923fc7a..c08d292 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,10 @@ name: CI jobs: lint: uses: ./.github/workflows/lint.yml - build-and-deploy: + build-and-deploy-stg: runs-on: ubuntu-latest + needs: + - lint steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -20,13 +22,25 @@ jobs: env: CI: true - uses: cloudflare/wrangler-action@1.3.0 - name: Deploy to Cloudflare + name: Deploy to Cloudflare (Staging) with: apiToken: "${{ secrets.CF_API_TOKEN }}" + environment: "staging" + k6-load-test: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: + - build-and-deploy-stg + steps: + - uses: actions/checkout@v3 + - uses: grafana/k6-action@v0.2.0 + name: Run k6 local test + with: + filename: scripts/test.js semantic-release: runs-on: ubuntu-latest needs: - - build-and-deploy + - k6-load-test steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -35,18 +49,26 @@ jobs: cache: npm - run: npm ci - run: npx semantic-release - name: Semantic Release + name: Run Semantic Release env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" NPM_TOKEN: "${{ secrets.NPM_TOKEN }}" - load-test: + build-and-deploy-prd: runs-on: ubuntu-latest - timeout-minutes: 30 needs: - - build-and-deploy + - k6-load-test steps: - uses: actions/checkout@v3 - - uses: grafana/k6-action@v0.2.0 - name: Run k6 test + - uses: actions/setup-node@v3 with: - filename: scripts/test.js + node-version: lts/* + cache: npm + - run: npm ci + - run: npm run build --if-present + env: + CI: true + - uses: cloudflare/wrangler-action@1.3.0 + name: Deploy to Cloudflare (Production) + with: + apiToken: "${{ secrets.CF_API_TOKEN }}" + environment: "production" diff --git a/scripts/test.js b/scripts/test.js index b975e35..feeda57 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -12,7 +12,7 @@ export const options = { let shortenLink -const BASE_URL = 'https://s.jerrynsh.com' +const BASE_URL = 'https://atomic-url-staging.jerrynsh.workers.dev/' const DUMMY_ORIGINAL_URL = 'https://jerrynsh.com/i-built-my-own-tiny-url/' export default function () {