|
| 1 | +name: Data-Platform (Staging) |
| 2 | +env: |
| 3 | + aws_deploy_region: "eu-west-2" |
| 4 | + terraform_state_s3_key_prefix: "data-platform" |
| 5 | + build_path: "." |
| 6 | + automation_build_url: "https://github.com/LBHackney-IT/data-platform/actions/workflows/deploy.yml" |
| 7 | +on: |
| 8 | + # This controls when a build will be triggered for a push. Unless you have a specific use case, this should be sufficient! |
| 9 | + push: |
| 10 | + branches: [main] |
| 11 | + paths-ignore: |
| 12 | + - "documentation/**" |
| 13 | + - "infrastructure/projects/**" |
| 14 | + - "infrastructure/platform/**" |
| 15 | + # This allows a manual trigger of the build, where a branch can be set. Please https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs |
| 16 | + # or delete if you don't wish to allow manual triggers of the build |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + terraform_import: |
| 20 | + description: "Terraform import statements" |
| 21 | + required: false |
| 22 | + terraform_remove: |
| 23 | + description: "Terraform state rm statements" |
| 24 | + required: false |
| 25 | + |
| 26 | +# Nothing to change down from here! |
| 27 | +# Pay no attention to the man behind the curtain |
| 28 | +jobs: |
| 29 | + deploy_stg: |
| 30 | + name: Deploy Staging |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout Source |
| 34 | + uses: actions/checkout@v2 |
| 35 | + - name: Set Node.js 14 |
| 36 | + uses: actions/setup-node@v2 |
| 37 | + with: |
| 38 | + node-version: "14" |
| 39 | + - name: Install dependencies in rds-database-snapshot-replicator lambda |
| 40 | + working-directory: "./lambdas/rds-database-snapshot-replicator/lambda" |
| 41 | + run: npm install |
| 42 | + - name: Set up Google Cloud Credentials |
| 43 | + run: | |
| 44 | + echo $GOOGLE_CREDENTIALS_STG >> ./google_service_account_creds.json |
| 45 | + shell: bash |
| 46 | + env: |
| 47 | + GOOGLE_CREDENTIALS_STG: ${{secrets.GOOGLE_CREDENTIALS_STG}} |
| 48 | + - name: Run AWS Terraform |
| 49 | + uses: ./.github/actions/aws-terraform |
| 50 | + with: |
| 51 | + environment: "stg" |
| 52 | + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 53 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 54 | + aws_deploy_region: "eu-west-2" |
| 55 | + terraform_state_s3_key_prefix: ${{ env.terraform_state_s3_key_prefix }} |
| 56 | + build_path: ${{ env.build_path }} |
| 57 | + automation_build_url: ${{ env.automation_build_url }} |
| 58 | + aws_deploy_account: ${{ secrets.AWS_ACCOUNT_DATA_PLATFORM_STG }} |
| 59 | + aws_api_account: ${{ secrets.AWS_API_ACCOUNT_STG }} |
| 60 | + aws_deploy_iam_role_name: ${{ secrets.AWS_ROLE_TO_ASSUME }} |
| 61 | + branch: ${GITHUB_REF##*/} |
| 62 | + terraform_import: ${{ github.event.inputs.terraform_import }} |
| 63 | + terraform_remove: ${{ github.event.inputs.terraform_remove }} |
| 64 | + # DANGER ZONE |
| 65 | + # In order to allow you to run a Terraform destroy (that will delete all AWS resources managed by Terraform, |
| 66 | + # you can set terraform_destroy: 'destroy_me'. Not providing a value or any other value except 'destroy_me' will |
| 67 | + # cause nothing to happen. The example here, with the value set to false is to ensure you've read this comment ;) |
| 68 | + terraform_destroy: false |
| 69 | + deploy_prod: |
| 70 | + name: Deploy Production |
| 71 | + needs: deploy_stg |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: Checkout Source |
| 75 | + uses: actions/checkout@v2 |
| 76 | + - name: Set Node.js 14 |
| 77 | + uses: actions/setup-node@v2 |
| 78 | + with: |
| 79 | + node-version: "14" |
| 80 | + - name: Install dependencies in rds-database-snapshot-replicator lambda |
| 81 | + working-directory: "./lambdas/rds-database-snapshot-replicator/lambda" |
| 82 | + run: npm install |
| 83 | + - name: Set up Google Cloud Credentials |
| 84 | + run: | |
| 85 | + echo $GOOGLE_CREDENTIALS_STG >> ./google_service_account_creds.json |
| 86 | + shell: bash |
| 87 | + env: |
| 88 | + GOOGLE_CREDENTIALS_STG: ${{secrets.GOOGLE_CREDENTIALS_STG}} |
| 89 | + - name: Run AWS Terraform |
| 90 | + uses: ./.github/actions/aws-terraform |
| 91 | + with: |
| 92 | + environment: "stg" |
| 93 | + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 94 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 95 | + aws_deploy_region: ${{ env.aws_deploy_region }} |
| 96 | + terraform_state_s3_key_prefix: ${{ env.terraform_state_s3_key_prefix }} |
| 97 | + build_path: ${{ env.build_path }} |
| 98 | + automation_build_url: ${{ env.automation_build_url }} |
| 99 | + aws_deploy_account: ${{ secrets.AWS_ACCOUNT_DATA_PLATFORM_STG }} |
| 100 | + aws_api_account: ${{ secrets.AWS_API_ACCOUNT_STG }} |
| 101 | + aws_deploy_iam_role_name: ${{ secrets.AWS_ROLE_TO_ASSUME }} |
| 102 | + branch: ${GITHUB_REF##*/} |
| 103 | + terraform_import: ${{ github.event.inputs.terraform_import }} |
| 104 | + terraform_remove: ${{ github.event.inputs.terraform_remove }} |
| 105 | + # DANGER ZONE |
| 106 | + # In order to allow you to run a Terraform destroy (that will delete all AWS resources managed by Terraform, |
| 107 | + # you can set terraform_destroy: 'destroy_me'. Not providing a value or any other value except 'destroy_me' will |
| 108 | + # cause nothing to happen. The example here, with the value set to false is to ensure you've read this comment ;) |
| 109 | + terraform_destroy: false |
0 commit comments