Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add preview link #300

Merged
merged 7 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Preview
on:
pull_request:

env:
ASSET_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.sha }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: Build
run: yarn build
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
build-storybook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: Build Storybook
run: yarn build-storybook -o dist/storybook
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
deploy-to-s3:
needs: [build, build-storybook]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- uses: shallwefootball/s3-upload-action@master
name: Upload trace to S3
if: always()
id: s3-trace
continue-on-error: true
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: noam-gaash.co.il
source_dir: dist
destination_dir: ${{ github.run_id }}/open-bus/${{ github.sha }}
- name: find comment
uses: peter-evans/find-comment@v1
if: github.event_name == 'pull_request'
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Preview'
- name: update comment
uses: peter-evans/create-or-update-comment@v1
if: steps.fc.outputs.comment-id
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.sha }}/index.html
Preview Storybook: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.sha }}/storybook/index.html
- name: create comment
uses: peter-evans/create-or-update-comment@v1
if: steps.fc.outputs.comment-id == ''
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.sha }}/index.html
Preview Storybook: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.sha }}/storybook/index.html
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

const ASSET_URL = process.env.ASSET_URL || ''

// https://vitejs.dev/config/
export default defineConfig({
base: ASSET_URL,
plugins: [react()],
resolve: {
alias: {
Expand Down
Loading