Skip to content

Commit

Permalink
update environments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Apr 23, 2024
1 parent b601d82 commit bf39cd8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ permissions:
id-token: write

jobs:
build_deploy:
deploy:
name: Build and deploy
uses: primer/.github/.github/workflows/deploy.yml@v2
uses: ./.github/workflows/tmp.deployment.yml
with:
node_version: 20
install: npm ci --legacy-peer-deps --no-audit --no-fund && npm run install:storybook
build: npm run build:next && cd docs/storybook && npm run build:prod
output_dir: docs/public
environment: Production (Storybook)

2 changes: 1 addition & 1 deletion .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
token: '${{ secrets.GITHUB_TOKEN }}'
environment-url: ${{needs.deploy.outputs.deployment_url}}storybook
environment: storybook-preview
environment: Preview (Storybook)
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v2
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/tmp.deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy to production environment

on:
workflow_call:
inputs:
install:
type: string
required: false
default: npm ci
build:
type: string
required: false
default: npm run build
output_dir:
type: string
required: false
default: public/
node_version:
type: number
required: true
default: 20
environment:
type: string
required: false
default: github-pages
secrets:
gh_token:
required: false

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "${{inputs.node_version}}"

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: ${{ inputs.install }}

- name: Build
run: ${{ inputs.build }}
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: ${{ inputs.output_dir }}

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
environment:
name: ${{ inputs.environment }}
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
preview: false

0 comments on commit bf39cd8

Please sign in to comment.