Dark mode (#34) #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Widget | |
on: | |
push: | |
branches: | |
- master | |
- staging | |
jobs: | |
deploy: | |
name: Deploy Widget | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Run Linter | |
run: npm run lint | |
- name: Bump Application Version and Tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: patch | |
default_prerelease_bump: prerelease | |
release_branches: master | |
pre_release_branches: staging | |
append_to_pre_release_tag: prerelease | |
- name: Build Application for Staging | |
if: github.ref == 'refs/heads/staging' | |
run: | | |
npm run build | |
npm run build:widget | |
env: | |
REACT_APP_WIDGET_ENVIRONMENT: 'staging' | |
REACT_APP_WIDGET_VERSION: ${{ steps.tag_version.outputs.new_tag }} | |
REACT_APP_WIDGET_URL: https://staging-widget.perscom.io | |
REACT_APP_API_URL: https://api.staging.perscom.io/v1/ | |
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
REACT_APP_SENTRY_SAMPLE_RATE: '1.0' | |
- name: Build Application for Production | |
if: github.ref == 'refs/heads/master' | |
run: | | |
npm run build | |
npm run build:widget | |
env: | |
REACT_APP_WIDGET_ENVIRONMENT: 'production' | |
REACT_APP_WIDGET_VERSION: ${{ steps.tag_version.outputs.new_tag }} | |
REACT_APP_WIDGET_URL: https://widget.perscom.io | |
REACT_APP_API_URL: https://api.perscom.io/v1/ | |
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
REACT_APP_SENTRY_SAMPLE_RATE: '0.1' | |
- name: Setup AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Deploy to S3 Staging | |
if: github.ref == 'refs/heads/staging' | |
run: | | |
aws s3 sync ./dist/ s3://${{ secrets.AWS_BUCKET_NAME_STAGING }} --delete | |
aws s3 sync ./build/ s3://${{ secrets.AWS_BUCKET_NAME_STAGING }} | |
- name: Deploy to S3 Production | |
if: github.ref == 'refs/heads/master' | |
run: | | |
aws s3 sync ./dist/ s3://${{ secrets.AWS_BUCKET_NAME_PRODUCTION }} --delete | |
aws s3 sync ./build/ s3://${{ secrets.AWS_BUCKET_NAME_PRODUCTION }} | |
- name: Invalidate Cloudfront Cache Staging | |
if: github.ref == 'refs/heads/staging' | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_STAGING }} | |
PATHS: "/*" | |
AWS_REGION: us-east-1 | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Invalidate Cloudfront Cache Production | |
if: github.ref == 'refs/heads/master' | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_PRODUCTION }} | |
PATHS: "/*" | |
AWS_REGION: us-east-1 | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Create Sentry Release Staging | |
if: github.ref == 'refs/heads/staging' | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: staging | |
version: ${{ steps.tag_version.outputs.new_tag }} | |
sourcemaps: ./dist | |
- name: Create Sentry Release Production | |
if: github.ref == 'refs/heads/master' | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
version: ${{ steps.tag_version.outputs.new_tag }} | |
sourcemaps: ./dist | |
- name: Create Github Release | |
uses: ncipollo/release-action@v1 | |
if: github.ref == 'refs/heads/master' | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: ${{ steps.tag_version.outputs.new_tag }} | |
generateReleaseNotes: true | |
makeLatest: true | |
token: ${{ secrets.RELEASE_TOKEN }} |