Merge pull request #11 from nimbus-gui/ra.test-pr-deployment-to-vercel
ci: test-commit for PR deployment
This commit is contained in:
commit
2fb34434e2
|
@ -1,6 +1,14 @@
|
||||||
name: 'UI tests'
|
name: 'UI tests'
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
- '!main'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
deployments: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cache-dependencies:
|
cache-dependencies:
|
||||||
|
@ -22,11 +30,16 @@ jobs:
|
||||||
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
build:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: cache-dependencies
|
needs: cache-dependencies
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Get PR number
|
||||||
|
id: pull_request
|
||||||
|
run: echo "::set-output name=number::$(gh pr view --json number -q .number || echo "")"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '18.x'
|
node-version: '18.x'
|
||||||
|
@ -42,6 +55,65 @@ jobs:
|
||||||
${{ runner.os }}-yarn-v3
|
${{ runner.os }}-yarn-v3
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
- name: Pull Vercel configuration
|
||||||
|
run: yarn vercel pull --yes --token ${{ secrets.vercel_token }}
|
||||||
|
- name: Build Vercel bundle
|
||||||
|
run: yarn vercel build
|
||||||
|
- name: Deploy to Vercel
|
||||||
|
run: yarn vercel deploy --prebuilt --token ${{ secrets.vercel_token }} > _vercel-deployment-url
|
||||||
|
- name: Comment on PR with deployment URL
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
issue_number: ${{ steps.pull_request.outputs.number }},
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: `Deployed to ${deploymentUrl}`,
|
||||||
|
});
|
||||||
|
- name: Add deployment to PR
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
id: deployment
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
||||||
|
const deployment = await github.rest.repos.createDeployment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
ref: context.sha,
|
||||||
|
environment: 'preview',
|
||||||
|
transient_environment: true,
|
||||||
|
required_contexts: [],
|
||||||
|
auto_merge: false,
|
||||||
|
production_environment: false,
|
||||||
|
payload: JSON.stringify({
|
||||||
|
deploymentUrl,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
console.log("::set-output name=deployment_id::" + deployment.data.id);
|
||||||
|
- name: Add deployment status to PR
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
||||||
|
await github.rest.repos.createDeploymentStatus({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }},
|
||||||
|
state: 'success',
|
||||||
|
environment_url: deploymentUrl,
|
||||||
|
log_url: deploymentUrl,
|
||||||
|
description: 'Deployed to Vercel',
|
||||||
|
environment: 'preview',
|
||||||
|
auto_inactive: true,
|
||||||
|
});
|
||||||
|
|
||||||
interaction-and-and-accessibility:
|
interaction-and-and-accessibility:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -71,42 +143,3 @@ jobs:
|
||||||
"npx http-server storybook-static --port 6006 --silent" \
|
"npx http-server storybook-static --port 6006 --silent" \
|
||||||
"npx wait-on tcp:127.0.0.1:6006 && yarn test-storybook"
|
"npx wait-on tcp:127.0.0.1:6006 && yarn test-storybook"
|
||||||
|
|
||||||
deployment:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: cache-dependencies
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '18.x'
|
|
||||||
- name: Restore yarn dependencies
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cache/Cypress
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-v3
|
|
||||||
- name: Log in to Vercel
|
|
||||||
run: yarn vercel login --token ${{ secrets.vercel_token }}
|
|
||||||
- name: Pull Vercel configuration
|
|
||||||
run: yarn vercel pull --yes
|
|
||||||
- name: Build Vercel bundle
|
|
||||||
run: yarn vercel build
|
|
||||||
- name: Deploy to Vercel
|
|
||||||
run: yarn vercel deploy --prebuilt > _vercel-deployment-url
|
|
||||||
- name: Comment on PR with deployment URL
|
|
||||||
uses: actions/github-script@v4
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
const fs = require('fs');
|
|
||||||
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
|
||||||
github.issues.createComment({
|
|
||||||
issue_number: context.issue.number,
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
body: `Deployed to ${deploymentUrl}`,
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue