Skip to content

Commit

Permalink
add deployment workflows for GitHub Pages (#778)
Browse files Browse the repository at this point in the history
* add base workflows

* update build commands in workflows
  • Loading branch information
rezrah committed Apr 20, 2022
1 parent 57105bb commit 46fd525
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 90 deletions.
65 changes: 16 additions & 49 deletions .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,19 @@
name: Deploy
name: Deploy preview
on:
push:
branches-ignore:
- 'main'
- 'dependabot/**'
paths:
- 'lib/**'
- 'icons/**'
- 'docs/**'
- '.github/workflows/deploy*.yml'
- 'package.json'
jobs:
deploy-preview:
if: ${{ github.repository == 'primer/octicons' }}
name: Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: chrnorm/deployment-action@v1.2.0
name: Create GitHub deployment
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: Preview

- name: Vercel Action
uses: amondnet/vercel-action@v20
id: vercel-action
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }}
github-comment: false
vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
pull_request:

- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment_url: ${{ steps.vercel-action.outputs.preview-url }}
state: "success"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
permissions:
contents: read
pages: write
id-token: write

- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
jobs:
deploy:
if: ${{ github.repository == 'primer/octicons' }}
name: Build and deploy
uses: primer/.github/.github/workflows/deploy_preview.yml@main
with:
node_version: 14
install: yarn
build: yarn build:docs:preview
output_dir: docs/public
36 changes: 17 additions & 19 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
name: Deploy
name: Deploy to production

on:
push:
branches:
- 'main'
- main
paths:
- 'lib/**'
- 'icons/**'
- 'docs/**'
- '.github/workflows/deploy*.yml'
- 'package.json'
jobs:
deploy:
if: ${{ github.repository == 'primer/octicons' }}
name: Production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Vercel Action
uses: amondnet/vercel-action@v20
id: vercel-action
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }}
vercel-args: '--prod'
github-comment: false
vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
permissions:
contents: read
pages: write
id-token: write

jobs:
build_deploy:
name: Build and deploy
uses: primer/.github/.github/workflows/deploy.yml@main
with:
node_version: 14
install: yarn
build: yarn build:docs
output_dir: docs/public
4 changes: 1 addition & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"repository": "primer/octicons",
"version": "1.0.0",
"scripts": {
"develop": "gatsby develop",
"prebuild": "pushd ..; yarn; yarn build; popd",
"build": "gatsby build --prefix-paths"
"develop": "gatsby develop"
},
"dependencies": {
"@primer/components": "^30.3.0",
Expand Down
15 changes: 0 additions & 15 deletions now.json

This file was deleted.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
"registry": "no registry, don't publish from this package.json."
},
"scripts": {
"version": "script/version",
"build": "script/build.js --input icons/**/*.svg --output lib/build/data.json",
"build:docs": "yarn build && cd docs && yarn gatsby build --prefix-paths",
"build:docs:preview": "yarn build && cd docs && yarn gatsby build",
"changeset:version": "changeset version && script/version",
"test": "ava -v tests/*.js",
"lint": "eslint tests",
"build": "script/build.js --input icons/**/*.svg --output lib/build/data.json",
"postinstall": "cd docs && yarn",
"start": "cd docs && npm run develop",
"svgo": "svgo icons --config .svgo.yml"
"svgo": "svgo icons --config .svgo.yml",
"test": "ava -v tests/*.js",
"version": "script/version"
},
"dependencies": {
"@changesets/changelog-github": "0.4.1",
Expand Down

0 comments on commit 46fd525

Please sign in to comment.