From bb0e946e038d30c4a799aae09a19142d6d5a9fec Mon Sep 17 00:00:00 2001 From: amalv <1252707+amalv@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:34:57 +0100 Subject: [PATCH] feat: split test workflow into separate deploy staging and test workflows --- .github/workflows/deploy_staging.yml | 47 +++++++++++++++++++++++++ .github/workflows/test.yml | 51 +++------------------------- 2 files changed, 52 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/deploy_staging.yml diff --git a/.github/workflows/deploy_staging.yml b/.github/workflows/deploy_staging.yml new file mode 100644 index 0000000..f946551 --- /dev/null +++ b/.github/workflows/deploy_staging.yml @@ -0,0 +1,47 @@ +name: Deploy to Staging +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install dependencies + run: npm install + - name: Build + run: npm run build + env: + VITE_API_URL_STAGING: ${{ secrets.VITE_API_URL_STAGING}} + VITE_AUTH0_DOMAIN: ${{ secrets.VITE_AUTH0_DOMAIN_STAGING }} + VITE_AUTH0_CLIENT_ID: ${{ secrets.VITE_AUTH0_CLIENT_ID_STAGING }} + VITE_ENV: staging + - name: Deploy to Netlify + id: deploy + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: "./dist" + production-branch: master + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Deploy from GitHub Actions" + enable-pull-request-comment: false + enable-commit-comment: true + overwrites-pull-request-comment: true + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 1 + - name: Save deploy URL + run: echo "${{ steps.deploy.outputs.deploy-url }}" > deploy-url.txt + - name: Upload deploy URL + uses: actions/upload-artifact@v4 + with: + name: deploy-url + path: deploy-url.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dced925..5f23aa3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,52 +1,11 @@ name: Run Tests on: - push: - pull_request: + workflow_run: + workflows: ["Deploy to Staging"] + types: + - completed jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "npm" - - name: Install dependencies - run: npm install - - name: Build - run: npm run build - env: - VITE_API_URL_STAGING: ${{ secrets.VITE_API_URL_STAGING}} - VITE_AUTH0_DOMAIN: ${{ secrets.VITE_AUTH0_DOMAIN_STAGING }} - VITE_AUTH0_CLIENT_ID: ${{ secrets.VITE_AUTH0_CLIENT_ID_STAGING }} - VITE_ENV: staging - - name: Deploy to Netlify - id: deploy - uses: nwtgck/actions-netlify@v2.0 - with: - publish-dir: "./dist" - production-branch: master - github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Deploy from GitHub Actions" - enable-pull-request-comment: false - enable-commit-comment: true - overwrites-pull-request-comment: true - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - timeout-minutes: 1 - - name: Save deploy URL - run: echo "${{ steps.deploy.outputs.deploy-url }}" > deploy-url.txt - - name: Upload deploy URL - uses: actions/upload-artifact@v4 - with: - name: deploy-url - path: deploy-url.txt - unit-tests: - needs: build runs-on: ubuntu-latest steps: - name: Checkout @@ -62,13 +21,13 @@ jobs: run: npm test e2e-tests: - needs: build runs-on: ubuntu-latest steps: - name: Download deploy URL uses: actions/download-artifact@v4 with: name: deploy-url + github-token: ${{ secrets.GH_PAT }} - name: Set deploy URL id: url run: echo "::set-output name=DEPLOY_URL::$(cat deploy-url.txt)"