1
1
mirror of https://github.com/primer/css.git synced 2024-12-11 11:16:04 +03:00
css/.github/workflows/deploy.yml

74 lines
2.3 KiB
YAML
Raw Normal View History

2021-04-05 20:25:49 +03:00
name: Deploy
2021-04-06 04:25:02 +03:00
on:
push:
paths:
- 'src/**'
- 'docs/**'
- '.github/workflows/deploy.yml'
- 'package.json'
2021-04-05 20:25:49 +03:00
jobs:
2021-04-06 04:31:49 +03:00
deploy:
# Run on main
if: ${{ github.ref == 'refs/heads/main' }}
name: Production
2021-04-06 02:02:51 +03:00
runs-on: ubuntu-latest
2021-04-05 20:25:49 +03:00
steps:
- uses: actions/checkout@master
2021-04-06 04:31:49 +03:00
# Check the number of changeset files, if it's 0 we deploy
2021-04-06 04:25:02 +03:00
- id: changeset-count
run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)"
2021-04-06 04:31:49 +03:00
2021-04-06 04:28:27 +03:00
- if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }}
2021-04-06 04:31:49 +03:00
name: Vercel Action
uses: amondnet/vercel-action@v20.0.0
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 }}
2021-04-06 04:25:02 +03:00
2021-04-06 04:31:49 +03:00
deploy-preview:
# Don't run on main
if: ${{ github.ref != 'refs/heads/main' }}
name: Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: Preview
2021-04-06 02:15:59 +03:00
2021-04-06 04:31:49 +03:00
- name: Vercel Action
uses: amondnet/vercel-action@v20.0.0
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 }}
2021-04-06 02:15:59 +03:00
2021-04-06 04:31:49 +03:00
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment_url: ${{ steps.vercel-action.outputs.preview-url }}
state: "success"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
2021-04-06 02:15:59 +03:00
2021-04-06 04:31:49 +03:00
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}