|
| 1 | +--- |
| 2 | +name: Production deployment |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | +jobs: |
| 8 | + set-state: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + path_prefix: ${{ steps.get_path_prefix.outputs.path_prefix }} |
| 12 | + branch_short_ref: ${{ steps.get_branch.outputs.branch }} |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Get pathPrefix |
| 18 | + uses: actions/github-script@v6 |
| 19 | + id: get_path_prefix |
| 20 | + with: |
| 21 | + script: | |
| 22 | + const script = require('./.github/scripts/get-path-prefix.js'); |
| 23 | + script({ core }); |
| 24 | + result-encoding: string |
| 25 | + - name: Get branch name |
| 26 | + shell: bash |
| 27 | + run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}" |
| 28 | + id: get_branch |
| 29 | + |
| 30 | + echo-state: |
| 31 | + needs: [set-state] |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - run: echo "Repository org - ${{ github.event.repository.owner.login }}" |
| 35 | + - run: echo "Repository name - ${{ github.event.repository.name }}" |
| 36 | + - run: echo "Repository branch - ${{ needs.set-state.outputs.branch_short_ref }}" |
| 37 | + - run: echo "Path prefix - ${{ needs.set-state.outputs.path_prefix }}" |
| 38 | + |
| 39 | + pre-build: |
| 40 | + needs: [set-state] |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: check prod azure connection string |
| 44 | + if: env.AIO_AZURE_PROD_CONNECTION_STRING == null |
| 45 | + run: | |
| 46 | + echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_PROD_CONNECTION_STRING in Github Secrets" |
| 47 | + exit 1 |
| 48 | + env: |
| 49 | + AIO_AZURE_PROD_CONNECTION_STRING: ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }} |
| 50 | + |
| 51 | + build: |
| 52 | + defaults: |
| 53 | + run: |
| 54 | + shell: bash |
| 55 | + needs: [set-state, pre-build] |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v3 |
| 60 | + |
| 61 | + - name: Setup Node v16 for Yarn v3 |
| 62 | + uses: actions/setup-node@v3 |
| 63 | + with: |
| 64 | + node-version: '16.15.0' # Current LTS version |
| 65 | + |
| 66 | + - name: Enable Corepack for Yarn v3 |
| 67 | + run: corepack enable |
| 68 | + |
| 69 | + - name: Install Yarn v3 |
| 70 | + uses: borales/actions-yarn@v3 |
| 71 | + with: |
| 72 | + cmd: set version stable |
| 73 | + |
| 74 | + - name: Install Dependencies |
| 75 | + uses: borales/actions-yarn@v3 |
| 76 | + env: |
| 77 | + YARN_ENABLE_IMMUTABLE_INSTALLS: false |
| 78 | + with: |
| 79 | + cmd: install |
| 80 | + |
| 81 | + - name: Gatsby Cache |
| 82 | + uses: actions/cache@v2 |
| 83 | + with: |
| 84 | + path: | |
| 85 | + public |
| 86 | + .cache |
| 87 | + key: ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }} |
| 88 | + restore-keys: | |
| 89 | + ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache- |
| 90 | +
|
| 91 | + - name: Build site |
| 92 | + uses: borales/actions-yarn@v3 |
| 93 | + with: |
| 94 | + cmd: build |
| 95 | + env: |
| 96 | + NODE_OPTIONS: "--max_old_space_size=4096" |
| 97 | + PREFIX_PATHS: true # equivalent to --prefix-paths flag for 'gatsby build' |
| 98 | + PATH_PREFIX: ${{ needs.set-state.outputs.path_prefix }} |
| 99 | + GATSBY_ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_PROD_SRC }} |
| 100 | + GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS: ${{ secrets.AIO_REPORT_SUITE_PROD }} |
| 101 | + GATSBY_ADOBE_ANALYTICS_ENV: 'production' |
| 102 | + REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + REPO_OWNER: ${{ github.event.repository.owner.login }} |
| 104 | + REPO_NAME: ${{ github.event.repository.name }} |
| 105 | + REPO_BRANCH: ${{ needs.set-state.outputs.branch_short_ref }} |
| 106 | + GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }} |
| 107 | + GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }} |
| 108 | + GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }} |
| 109 | + GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }} |
| 110 | + GATSBY_IMS_SRC: ${{ secrets.AIO_IMS_PROD_SRC }} |
| 111 | + GATSBY_IMS_CONFIG: ${{ secrets.AIO_IMS_PROD_CONFIG }} |
| 112 | + GATSBY_ALGOLIA_APPLICATION_ID: ${{ secrets.AIO_ALGOLIA_APPLICATION_ID }} |
| 113 | + GATSBY_ALGOLIA_SEARCH_API_KEY: ${{ secrets.AIO_ALGOLIA_SEARCH_API_KEY }} |
| 114 | + ALGOLIA_INDEXATION_MODE: skip |
| 115 | + GATSBY_ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME || github.event.repository.name }} |
| 116 | + GATSBY_FEDS_PRIVACY_ID: ${{ secrets.AIO_FEDS_PRIVACY_ID }} |
| 117 | + GATSBY_SITE_DOMAIN_URL: https://developer.adobe.com |
| 118 | + - name: Deploy |
| 119 | + uses: icaraps/static-website-deploy@master |
| 120 | + with: |
| 121 | + enabled-static-website: 'true' |
| 122 | + source: 'public' |
| 123 | + target: ${{ needs.set-state.outputs.path_prefix }} |
| 124 | + connection-string: ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }} |
| 125 | + remove-existing-files: 'true' |
| 126 | + - name: Delay purge |
| 127 | + run: sleep 60s |
| 128 | + shell: bash |
| 129 | + - name: Purge Fastly Cache |
| 130 | + uses: icaraps/gatsby-fastly-purge-action@master |
| 131 | + with: |
| 132 | + fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }} |
| 133 | + fastly-url: '${{ secrets.AIO_FASTLY_PROD_URL }}${{ needs.set-state.outputs.path_prefix }}' |
0 commit comments