Separate browser build #19
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: Main | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: "us-east-1" | |
CDN_DISTRIBUTION_ID: "EIY5G2ECS6996" | |
S3_BUCKET: "schematic-cdn" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- name: Run install | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: install | |
- name: Build production bundle | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Get package version | |
id: package | |
run: | | |
echo "::set-output name=version::$(node -p "require('./package.json').version")" | |
- name: Publish browser build | |
run: | | |
aws s3 cp --acl=public-read dist/main.js s3://$S3_BUCKET/js/schematic.js | |
aws s3 cp --acl=public-read dist/main.js s3://$S3_BUCKET/js/schematic.${{ steps.package.outputs.version }}.js | |
aws configure set preview.cloudfront true | |
aws cloudfront create-invalidation --distribution-id ${{ env.CDN_DISTRIBUTION_ID }} --paths "/js/schematic.js" "/js/schematic.${{ steps.package.outputs.version }}.js" | |
notify_slack: | |
name: Notify Slack | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
steps: | |
- uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_TITLE: Updated schematic-js | |
SLACK_ICON: https://schematic-public-assets.s3.amazonaws.com/logos/logo-transparent.png |