-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Only merge using a merge commit!**
- Loading branch information
Showing
15 changed files
with
191 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ on: | |
workflow_call: | ||
|
||
jobs: | ||
plan: | ||
build-email-function: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: terraform apply | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Target environment" | ||
required: true | ||
default: "test" | ||
type: choice | ||
options: | ||
- test | ||
|
||
jobs: | ||
plan: | ||
uses: ./.github/workflows/terraform-plan.yml | ||
with: | ||
environment: ${{ inputs.environment }} | ||
workflow_call: true | ||
secrets: inherit | ||
|
||
apply: | ||
runs-on: ubuntu-22.04 | ||
|
||
# Related | ||
# - https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | ||
# - https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps | ||
permissions: | ||
id-token: write # Required for aws-actions/configure-aws-credentials | ||
contents: read # Required for aws-actions/configure-aws-credentials | ||
|
||
needs: [plan] | ||
|
||
environment: "terraform-${{ inputs.environment }}" | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Read .terraform-version | ||
id: terraform_version | ||
run: echo "value=$(cat .terraform-version)" >> $GITHUB_OUTPUT | ||
working-directory: terraform | ||
|
||
- uses: hashicorp/[email protected] | ||
with: | ||
terraform_version: "${{ steps.terraform_version.outputs.value }}" | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ vars.IAM_ROLE_ARN }} | ||
aws-region: eu-central-1 | ||
|
||
- name: Retrieve email-function artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: email-function-dist | ||
path: bun-packages/packages/email-function/dist | ||
|
||
- name: Retrieve tfplan artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: tfplan | ||
path: terraform/ | ||
|
||
- name: terraform init | ||
run: terraform init -backend-config=${{ inputs.environment }}.s3.tfbackend | ||
working-directory: terraform | ||
|
||
- name: terraform apply | ||
run: terraform apply tfplan | ||
working-directory: terraform | ||
env: | ||
TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
TF_VAR_api_subdomain: ${{ vars.API_SUBDOMAIN }} | ||
TF_VAR_email_function_parameters: ${{ secrets.EMAIL_FUNCTION_PARAMETERS }} | ||
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,27 @@ on: | |
- terraform/** | ||
- bun-packages/** | ||
- cloudformation/** | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Target environment" | ||
required: true | ||
default: "test" | ||
type: choice | ||
options: | ||
- test | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
default: "test" | ||
type: string | ||
|
||
# `github.event_name` is `workflow_dispatch` even for `workflow_call`. | ||
# https://github.com/actions/runner/discussions/1884 | ||
workflow_call: | ||
required: false | ||
type: boolean | ||
|
||
jobs: | ||
build_email_function: | ||
|
@@ -29,6 +50,8 @@ jobs: | |
|
||
needs: [build_email_function] | ||
|
||
environment: terraform-${{ inputs.environment || 'test' }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
|
@@ -44,7 +67,7 @@ jobs: | |
- name: Configure AWS Credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: arn:aws:iam::220746603587:role/github-actions | ||
role-to-assume: ${{ vars.IAM_ROLE_ARN }} | ||
aws-region: eu-central-1 | ||
|
||
- name: Retrieve email-function artifact | ||
|
@@ -54,17 +77,18 @@ jobs: | |
path: bun-packages/packages/email-function/dist | ||
|
||
- name: terraform init | ||
run: terraform init -backend-config=test.s3.tfbackend | ||
run: terraform init -backend-config=${{ inputs.environment || 'test' }}.s3.tfbackend | ||
working-directory: terraform | ||
|
||
- name: terraform plan | ||
run: terraform plan -no-color | ||
run: terraform plan -no-color -out=tfplan | ||
working-directory: terraform | ||
id: plan | ||
continue-on-error: true | ||
env: | ||
TF_VAR_cloudflare_api_token: ${{ secrets.TF_VAR_CLOUDFLARE_API_TOKEN }} | ||
TF_VAR_api_subdomain: sinister-api-test | ||
TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
TF_VAR_api_subdomain: ${{ vars.API_SUBDOMAIN }} | ||
TF_VAR_email_function_parameters: ${{ secrets.EMAIL_FUNCTION_PARAMETERS }} | ||
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
|
||
- uses: actions/[email protected] | ||
|
@@ -116,3 +140,11 @@ jobs: | |
- name: Break on terraform plan failure | ||
if: steps.plan.outcome == 'failure' | ||
run: exit 1 | ||
|
||
- name: Store artifact | ||
uses: actions/[email protected] | ||
if: inputs.workflow_call | ||
with: | ||
name: tfplan | ||
path: terraform/tfplan | ||
retention-days: 1 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test-parameters.json | ||
prod-parameters.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.