|
| 1 | +name: Deploy To Prod EU |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - released |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | +env: |
| 13 | + GOLANG_VERSION: 1.23 |
| 14 | + REGION_NAME: eu-west-1 |
| 15 | + ACCOUNT_ID: 247286868737 |
| 16 | + ROLE_TO_ASSUME: arn:aws:iam::247286868737:role/firetail-prod-github-serverless-lambda-deployment |
| 17 | + LAMBDA_SERVERLESS_REPO: firetail-prod-eu-west-1-serverless-applications |
| 18 | + APP_NAME: firetail-appsync-logger |
| 19 | + CFN_TEMPLATES_BUCKET: firetail-prod-us-east-1-cf-templates |
| 20 | + CFN_TEMPLATES_BUCKET_REGION: us-east-1 |
| 21 | +jobs: |
| 22 | + setup: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + mymatrix: ${{ steps.matrixStep.outputs.matrixItems }} |
| 26 | + steps: |
| 27 | + - name: Checkout Code |
| 28 | + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 |
| 29 | + with: |
| 30 | + fetch-depth: 2 |
| 31 | + - name: Configure AWS Credentials |
| 32 | + uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 |
| 33 | + with: |
| 34 | + aws-region: ${{ env.REGION_NAME }} |
| 35 | + role-to-assume: ${{env.ROLE_TO_ASSUME }} |
| 36 | + role-session-name: github |
| 37 | + - id: matrixStep |
| 38 | + run: | |
| 39 | + python3 -m pip install boto3 |
| 40 | + matrix=$(python3 build_setup/get_regions.py) |
| 41 | + echo $matrix |
| 42 | + echo "matrixItems=$(echo $matrix)" >> $GITHUB_ENV |
| 43 | + download-artifact: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - name: Checkout Code |
| 47 | + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 |
| 48 | + with: |
| 49 | + fetch-depth: 2 |
| 50 | + - name: Get Release |
| 51 | + id: get_release |
| 52 | + uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ github.token }} |
| 55 | + - name: Download zip from release |
| 56 | + uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51 |
| 57 | + with: |
| 58 | + releaseId: ${{ steps.get_release.outputs.id }} |
| 59 | + fileName: lambda.zip |
| 60 | + out-file-path: "build" |
| 61 | + - name: Configure AWS Credentials |
| 62 | + uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 |
| 63 | + with: |
| 64 | + aws-region: ${{ env.REGION_NAME }} |
| 65 | + role-to-assume: ${{env.ROLE_TO_ASSUME }} |
| 66 | + role-session-name: github |
| 67 | + - run: |
| 68 | + sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket ${{ |
| 69 | + env.LAMBDA_SERVERLESS_REPO }} --region ${{env.REGION_NAME}} |
| 70 | + - uses: actions/upload-artifact@v3 |
| 71 | + with: |
| 72 | + name: packaged.yaml |
| 73 | + path: packaged.yaml |
| 74 | + release-application: |
| 75 | + needs: download-artifact |
| 76 | + runs-on: ubuntu-latest |
| 77 | + strategy: |
| 78 | + # matrix: ${{ fromJson(needs.setup.outputs.mymatrix) }} |
| 79 | + fail-fast: false |
| 80 | + matrix: |
| 81 | + region: |
| 82 | + [ |
| 83 | + "us-east-2", |
| 84 | + "us-east-1", |
| 85 | + "us-west-1", |
| 86 | + "us-west-2", |
| 87 | + "af-south-1", |
| 88 | + "ap-east-1", |
| 89 | + "ap-south-2", |
| 90 | + "ap-southeast-3", |
| 91 | + "ap-southeast-4", |
| 92 | + "ap-south-1", |
| 93 | + "ap-northeast-3", |
| 94 | + "ap-northeast-2", |
| 95 | + "ap-southeast-1", |
| 96 | + "ap-southeast-2", |
| 97 | + "ap-northeast-1", |
| 98 | + "ca-central-1", |
| 99 | + "eu-central-1", |
| 100 | + "eu-west-1", |
| 101 | + "eu-west-2", |
| 102 | + "eu-south-1", |
| 103 | + "eu-west-3", |
| 104 | + "eu-south-2", |
| 105 | + "eu-north-1", |
| 106 | + "eu-central-2", |
| 107 | + "il-central-1", |
| 108 | + "me-south-1", |
| 109 | + "me-central-1", |
| 110 | + "sa-east-1", |
| 111 | + ] |
| 112 | + steps: |
| 113 | + - name: Configure AWS Credentials |
| 114 | + uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 |
| 115 | + with: |
| 116 | + aws-region: ${{ env.REGION_NAME }} |
| 117 | + role-to-assume: ${{env.ROLE_TO_ASSUME }} |
| 118 | + role-session-name: github |
| 119 | + - name: Get Release |
| 120 | + id: get_release |
| 121 | + uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f |
| 122 | + env: |
| 123 | + GITHUB_TOKEN: ${{ github.token }} |
| 124 | + - uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: packaged.yaml |
| 127 | + - run: | |
| 128 | + version=$(echo "${{ steps.get_release.outputs.tag_name }}" | cut -c 2-) |
| 129 | + sam publish --template packaged.yaml --region ${{ matrix.region }} --semantic-version $version |
| 130 | + aws serverlessrepo put-application-policy --region ${{ matrix.region }} --application-id arn:aws:serverlessrepo:${{ matrix.region }}:${{env.ACCOUNT_ID}}:applications/${{env.APP_NAME}} --statements Principals=*,Actions=Deploy |
| 131 | + continue-on-error: true |
| 132 | + release-cloudformation: |
| 133 | + needs: release-application |
| 134 | + runs-on: ubuntu-latest |
| 135 | + timeout-minutes: 15 |
| 136 | + steps: |
| 137 | + - name: Checkout Code |
| 138 | + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 |
| 139 | + with: |
| 140 | + fetch-depth: 2 |
| 141 | + - name: Get Release |
| 142 | + id: get_release |
| 143 | + uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f |
| 144 | + env: |
| 145 | + GITHUB_TOKEN: ${{ github.token }} |
| 146 | + - run: | |
| 147 | + version=$(echo "${{ steps.get_release.outputs.tag_name }}" | cut -c 2-) |
| 148 | + sed -i -e "s/0.0.1/${version}/g" cfn_templates/appsync_logging_template.yaml |
| 149 | + - name: Configure AWS Credentials |
| 150 | + uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 |
| 151 | + with: |
| 152 | + aws-region: ${{ env.REGION_NAME }} |
| 153 | + role-to-assume: ${{env.ROLE_TO_ASSUME }} |
| 154 | + role-session-name: github |
| 155 | + - name: copy new cfn to s3 |
| 156 | + run: | |
| 157 | + aws s3 cp ./cfn_templates/ s3://${{env.CFN_TEMPLATES_BUCKET}}/applications/cfn/ --acl public-read --region ${{env.CFN_TEMPLATES_BUCKET_REGION}} --recursive |
0 commit comments