Skip to content

Commit

Permalink
Set up .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaul committed Jun 5, 2024
1 parent 4874901 commit 8ab9319
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set one of these to true, depending on whether you want the custom site or
# the storybook as your jump-start frontend
DEPLOY_CUSTOM_SITE=true
DEPLOY_STORYBOOK=false

# GITHUB_USERNAME=
# GITHUB_REPO=

# Set this to tar (default) or git (slower, but works with private repos)
DEGIT_MODE=tar
36 changes: 18 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
name: Deploy to Pages

env:
# Set one of these to true, depending on whether you want the custom site or
# the storybook as your jump-start frontend
DEPLOY_CUSTOM_SITE: true
DEPLOY_STORYBOOK: false

on:
# Runs on pushes targeting the default branch
push:
Expand All @@ -32,12 +26,18 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.repository != 'kevinschaul/jump-start-template' }}
env:
JUMP_START_GITHUB_USERNAME: ${{ github.repository_owner }}
JUMP_START_GITHUB_REPO: ${{ github.event.repository.name }}
GITHUB_USERNAME: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Dotenv
id: dotenv
uses: falti/dotenv-action@v1.1.2
with:
keys-case: bypass

- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -66,13 +66,13 @@ jobs:
git push
- name: Set up Python
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
uses: actions/setup-python@v5
with:
python-version: '3.10'

- uses: actions/cache@v4
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
name: Configure pip caching
with:
path: ~/.cache/pip
Expand All @@ -81,50 +81,50 @@ jobs:
${{ runner.os }}-pip-
- name: Cache Playwright browsers
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright/
key: ${{ runner.os }}-browsers

- name: Install Python dependencies
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
run: |
pip install -r jump-start-gallery/requirements.txt
- name: Install Playwright dependencies
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
run: |
shot-scraper install
- name: Start server and take screenshots
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
run: |
mkdir -p jump-start-gallery/public/screenshots &&
npm run dev &
sleep 2 &&
npm run update-screenshots
- name: Build custom site
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
env:
GITHUB_PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }}
run: npm run build

- name: Upload custom site artifact
if: ${{ env.DEPLOY_CUSTOM_SITE == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_CUSTOM_SITE == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ./jump-start-gallery/dist

- name: Build storybook
if: ${{ env.DEPLOY_STORYBOOK == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_STORYBOOK == 'true' }}
env:
GITHUB_PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }}
run: npm run build-storybook

- name: Upload custom site artifact
if: ${{ env.DEPLOY_STORYBOOK == 'true' }}
if: ${{ steps.dotenv.outputs.DEPLOY_STORYBOOK == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ./jump-start-gallery/storybook-static
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ Open localhost:6006 in a browser.
## Deploying the gallery to Github Pages

This repo includes a [deploy workflow](.github/workflows/deploy.yml) that
deploys your jump start gallery to Github pages. By default the custom gallery
frontend is used, but you can edit the env variables at the top of the workflow
file to deploy the Storybook version instead.
deploys your jump start gallery to Github pages. By default the custom
gallery frontend is used, but you can edit the env variables in
[.env](.env) to deploy the Storybook version instead.

## Updating the gallery code

Expand Down
2 changes: 1 addition & 1 deletion jump-start-gallery
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"gallery:clone": "git submodule update --init",
"gallery:update": "git submodule sync --recursive",
"gallery:install": "cd jump-start-gallery && npm install",
"gallery:link": "cd jump-start-gallery && rm -f src/starters && ln -sf ../../ src/starters"
"gallery:link": "cd jump-start-gallery && rm -f src/starters && ln -sf ../../ src/starters && rm -rf .env && ln -sf ../.env .env"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 8ab9319

Please sign in to comment.