|
| 1 | +# Copyright 2024 EPAM Systems |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# |
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | + |
| 14 | +name: Deploy to dev base (AWS S3) |
| 15 | +env: |
| 16 | + AWS_S3_BUCKET_NAME : rpp-landing |
| 17 | + AWS_REGION_NAME : eu-central-1 |
| 18 | + BUILD_DIR : public/ |
| 19 | + CONTACT_US_URL: https://testio--partial.sandbox.my.salesforce-sites.com/leadcapture/services/apexrest/leadservice |
| 20 | + DOCUMENTATION_URL: //reportportal.io/docs |
| 21 | + GTM_ID: GTM-MK7ZHTL |
| 22 | + CLOUDFRONT_ID: EILUB1IE9EON0 |
| 23 | + CONTENTFUL_ENV_ID: master |
| 24 | + CONTENTFUL_HOST: cdn.contentful.com |
| 25 | + GATSBY_MAILCHIMP_LIST_ID: ca6d0eec5b |
| 26 | + CONTENTFUL_ACCESS_TOKEN: ${{ inputs.CONTENTFUL_ACCESS_TOKEN }} |
| 27 | + |
| 28 | +on: |
| 29 | + workflow_call: |
| 30 | + inputs: |
| 31 | + CONTENTFUL_ACCESS_TOKEN: |
| 32 | + type: string |
| 33 | + required: true |
| 34 | + |
| 35 | +jobs: |
| 36 | + empty-s3-bucket: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Set AWS credentials |
| 40 | + uses: aws-actions/configure-aws-credentials@v1 |
| 41 | + with: |
| 42 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 43 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 44 | + aws-region: ${{ env.AWS_REGION_NAME }} |
| 45 | + |
| 46 | + - name: Empty AWS S3 bucket |
| 47 | + run: aws s3 rm s3://${{ env.AWS_S3_BUCKET_NAME }} --recursive |
| 48 | + |
| 49 | + deploy: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: [empty-s3-bucket] |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Set up Node.js |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: 18 |
| 60 | + |
| 61 | + - name: Install of node dependencies |
| 62 | + run: npm install |
| 63 | + |
| 64 | + - name: create env file |
| 65 | + run: | |
| 66 | + touch .env.production |
| 67 | + echo CONTENTFUL_ACCESS_TOKEN=${{ env.CONTENTFUL_ACCESS_TOKEN }} >> .env.production |
| 68 | + echo CONTENTFUL_SPACE_ID=${{ secrets.CONTENTFUL_SPACE_ID_DEV }} >> .env.production |
| 69 | + echo CONTENTFUL_ENV_ID=${{ env.CONTENTFUL_ENV_ID }} >> .env.production |
| 70 | + echo CONTENTFUL_HOST=${{ env.CONTENTFUL_HOST }} >> .env.production |
| 71 | + echo GTM_ID=${{ env.GTM_ID }} >> .env.production |
| 72 | + echo CONTACT_US_URL=${{ env.CONTACT_US_URL }} >> .env.production |
| 73 | + echo DOCUMENTATION_URL=${{ env.DOCUMENTATION_URL }} >> .env.production |
| 74 | + echo GATSBY_MAILCHIMP_LIST_ID=${{ env.GATSBY_MAILCHIMP_LIST_ID }} >> .env.production |
| 75 | +
|
| 76 | + - name: Build the source code |
| 77 | + run: npm run build |
| 78 | + |
| 79 | + - name: Set AWS credentials |
| 80 | + uses: aws-actions/configure-aws-credentials@v1 |
| 81 | + with: |
| 82 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 83 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 84 | + aws-region: ${{ env.AWS_REGION_NAME }} |
| 85 | + |
| 86 | + - name: Deploy to AWS S3 |
| 87 | + run: aws s3 sync ./${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET_NAME }} |
| 88 | + |
| 89 | + - name: Clearing CloudFront cache for the entire distribution |
| 90 | + run: aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_ID }} --paths "/*" |
0 commit comments