Merge pull request #1406 from brave/master #146
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 to Production | |
on: | |
push: | |
branches: [prod] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: https://ads.brave.com | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install pnpm | |
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3 | |
- name: Use Node.js | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version-file: ".node-version" | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- run: pnpm check | |
- name: Build | |
env: | |
REACT_APP_SERVER_ADDRESS: ${{ secrets.REACT_PRODUCTION_APP_SERVER_ADDRESS }} | |
REACT_APP_GIT_SHA1: ${{ github.sha }} | |
run: | | |
export REACT_APP_BUILD_TIME=$(date -Iseconds) | |
pnpm build | |
- run: pnpm test | |
- name: Deploy static files | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PRODUCTION_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PRODUCTION_SECRET_ACCESS_KEY }} | |
AWS_REGION: us-west-2 | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_PRODUCTION_DISTRIBUTION_ID }} | |
run: | | |
cd build | |
aws s3 sync ./static/ "s3://ads-ui-production/static/" --cache-control "max-age=31536000, public" | |
aws s3 sync . "s3://ads-ui-production/" --exclude "static/*" --cache-control "max-age=60, public" | |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" |