diff --git a/.github/workflows/deploy-api-lambda-edge.yml b/.github/workflows/deploy-api-lambda-edge.yml new file mode 100644 index 000000000..bb985b463 --- /dev/null +++ b/.github/workflows/deploy-api-lambda-edge.yml @@ -0,0 +1,15 @@ +name: "Deploy API Lambda (edge)" + +on: + push: + branches: + - main + +permissions: + contents: read + +jobs: + deploy: + uses: ./.github/workflows/deploy-api-lambda.yml + with: + environment: edge diff --git a/.github/workflows/deploy-api-lambda-prod.yml b/.github/workflows/deploy-api-lambda-prod.yml new file mode 100644 index 000000000..9d43d5db3 --- /dev/null +++ b/.github/workflows/deploy-api-lambda-prod.yml @@ -0,0 +1,19 @@ +name: "Deploy API Lambda (prod)" + +on: + workflow_dispatch: + inputs: + ref: + description: 'The git tag of the release to deploy, e.g. 3.0.0' + required: true + type: string + +permissions: + contents: read + +jobs: + deploy: + uses: ./.github/workflows/deploy-api-lambda.yml + with: + environment: prod + ref: refs/tags/${{ github.event.inputs.ref }} diff --git a/.github/workflows/deploy-api-lambda-staging.yml b/.github/workflows/deploy-api-lambda-staging.yml new file mode 100644 index 000000000..f5fedfe7c --- /dev/null +++ b/.github/workflows/deploy-api-lambda-staging.yml @@ -0,0 +1,16 @@ +name: "Deploy API Lambda (staging)" + +on: + release: + types: + - published + +permissions: + contents: read + +jobs: + deploy: + uses: ./.github/workflows/deploy-api-lambda.yml + with: + environment: staging + ref: refs/tags/${{ github.event.release.tag_name }} diff --git a/.github/workflows/deploy-api-lambda.yml b/.github/workflows/deploy-api-lambda.yml index ca4ae2c52..790e018d0 100644 --- a/.github/workflows/deploy-api-lambda.yml +++ b/.github/workflows/deploy-api-lambda.yml @@ -1,9 +1,16 @@ name: Deploy API Lambda + on: - push: - branches: - - main - workflow_dispatch: + workflow_call: + inputs: + environment: + required: true + type: string + description: edge, staging or prod + ref: + required: false + type: string + default: ${{ github.ref }} permissions: contents: read @@ -13,23 +20,21 @@ jobs: permissions: contents: read uses: ./.github/workflows/build-api-lambda.yml - + with: + ref: ${{ inputs.ref }} + deploy: - concurrency: ${{ github.workflow }} + concurrency: ${{ github.workflow }}-${{ inputs.environment }} permissions: contents: read id-token: write runs-on: ubuntu-latest needs: build - environment: docs-api-edge + environment: docs-api-${{ inputs.environment }} env: ZIP_FILE: api-lambda.zip steps: - uses: actions/checkout@v5 - - name: Download bootstrap binary - uses: actions/download-artifact@v4 - with: - name: api-lambda-binary - name: Download bootstrap binary uses: actions/download-artifact@v4 @@ -42,11 +47,13 @@ jobs: - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 with: - role-to-assume: arn:aws:iam::197730964718:role/elastic-docs-v3-api-deployer-edge + role-to-assume: arn:aws:iam::197730964718:role/elastic-docs-v3-api-deployer-${{ inputs.environment }} aws-region: us-east-1 - name: Upload Lambda function run: | aws lambda update-function-code \ - --function-name elastic-docs-v3-edge-api \ + --function-name "elastic-docs-v3-${ENVIRONMENT}-api" \ --zip-file "fileb://${ZIP_FILE}" + env: + ENVIRONMENT: ${{ inputs.environment }}