|
| 1 | +name: Prod Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v1 |
| 15 | + - uses: actions/setup-node@master |
| 16 | + with: |
| 17 | + node-version: '14' |
| 18 | + - name: set AWS, BFF, NewRelic and Algolia Keys to environment |
| 19 | + env: |
| 20 | + GATSBY_ALGOLIA_APP_ID: ${{ secrets.GATSBY_ALGOLIA_APP_ID}} |
| 21 | + GATSBY_ALGOLIA_SEARCH_KEY: ${{secrets.GATSBY_ALGOLIA_SEARCH_KEY}} |
| 22 | + ALGOLIA_ADMIN_KEY: ${{secrets.ALGOLIA_ADMIN_KEY}} |
| 23 | + AWS_ACCESS_KEY_ID: ${{secrets.PROD_AWS_ACCESS_KEY_ID}} |
| 24 | + AWS_SECRET_ACCESS_KEY: ${{secrets.PROD_AWS_SECRET_ACCESS_KEY}} |
| 25 | + DIST_ID: ${{secrets.PROD_DIST_ID}} |
| 26 | + MUNCHKIN_ID: ${{ secrets.MUNCHKIN_ID}} |
| 27 | + BFF_BLOG_URL: ${{ secrets.BFF_BLOG_URL }} |
| 28 | + BFF_EVENTS_URL: ${{ secrets.BFF_EVENTS_URL }} |
| 29 | + BFF_PING_WEBHOOK_URL: ${{ secrets.BFF_PING_WEBHOOK_URL }} |
| 30 | + RELIC_ACCOUNT_ID: ${{ secrets.RELIC_ACCOUNT_ID }} |
| 31 | + RELIC_TRUST_KEY: ${{ secrets.RELIC_TRUST_KEY }} |
| 32 | + RELIC_LICENSE_KEY: ${{ secrets.RELIC_LICENSE_KEY }} |
| 33 | + RELIC_PRODUCTION_AGENT_ID: ${{ secrets.RELIC_PRODUCTION_AGENT_ID }} |
| 34 | + RELIC_PRODUCTION_APPLICATION_ID: ${{ secrets.RELIC_PRODUCTION_APPLICATION_ID }} |
| 35 | + PM_TECH: ${{secrets.PM_TECH}} |
| 36 | + SITE_URL: ${{secrets.SITE_URL_PROD}} |
| 37 | + |
| 38 | + run: | |
| 39 | + npm config set //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}} |
| 40 | + npm install |
| 41 | + npm run clean |
| 42 | + npm run build:prod && node_modules/s3-deploy/bin/s3-deploy './public/**' --cwd './public/' --bucket postman-learning-center-prod --deleteRemoved --distId $DIST_ID --invalidate '/*' |
| 43 | + - name: update Algolia with GA Pageviews |
| 44 | + env: |
| 45 | + ALGOLIA_ADMIN_KEY: ${{secrets.ALGOLIA_ADMIN_KEY}} |
| 46 | + GOOGLE_ALGOLIA_CREDENTIALS: ${{secrets.GOOGLE_ALGOLIA_CREDENTIALS}} |
| 47 | + GOOGLE_PROJECT_ID: ${{secrets.GOOGLE_PROJECT_ID}} |
| 48 | + GOOGLE_PRIVATE_KEY: ${{secrets.GOOGLE_PRIVATE_KEY}} |
| 49 | + GOOGLE_PRIVATE_KEY_2: ${{secrets.GOOGLE_PRIVATE_KEY_2}} |
| 50 | + GOOGLE_CLIENT_EMAIL: ${{secrets.GOOGLE_CLIENT_EMAIL}} |
| 51 | + GOOGLE_CLIENT_ID: ${{secrets.GOOGLE_CLIENT_ID}} |
| 52 | + GOOGLE_AUTH_CERT: ${{secrets.GOOGLE_AUTH_CERT}} |
| 53 | + GOOGLE_CLIENT_CERT: ${{secrets.GOOGLE_CLIENT_CERT}} |
| 54 | + PM_TECH: ${{secrets.PM_TECH}} |
| 55 | + run: | |
| 56 | + npm config set //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}} |
| 57 | + npm install; |
| 58 | + type=service_account project_id=$GOOGLE_PROJECT_ID private_key_id=$GOOGLE_PRIVATE_KEY private_key=$GOOGLE_PRIVATE_KEY_2 client_email=$GOOGLE_CLIENT_EMAIL client_id=$GOOGLE_CLIENT_ID auth_uri=https://accounts.google.com/o/oauth2/auth token_uri=https://oauth2.googleapis.com/token auth_provider_x509_cert_url=$GOOGLE_AUTH_CERT client_x509_cert_url=$GOOGLE_CLIENT_CERT node -p -e 'const {type,private_key_id,private_key,project_id,client_email,client_id,auth_uri,token_uri,auth_provider_x509_cert_url,client_x509_cert_url} = process.env; require("fs").writeFile("auth.json", JSON.stringify({type,project_id,private_key_id,private_key:private_key.replace(/\\n/g,"\n"),client_email,client_id,auth_uri,token_uri,auth_provider_x509_cert_url,client_x509_cert_url},null,2), err=>{})' |
| 59 | + GOOGLE_APPLICATION_CREDENTIALS=auth.json ALGOLIA_ADMIN_KEY=$ALGOLIA_ADMIN_KEY node ga_connector.js; |
| 60 | + rm -rf auth.json |
| 61 | +
|
0 commit comments