Add github actions

maybe
This commit is contained in:
Michaela Wheeler 2021-11-12 22:47:43 +11:00 committed by GitHub
parent 831da1cfc3
commit 8196780847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 676 additions and 566 deletions

41
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: 'Terraform GitHub Actions'
on:
push:
branches:
- main
env:
tf_version: 'latest'
tf_working_dir: '.'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
terraform:
environment: main
name: 'Terraform'
runs-on: ubuntu-latest
steps:
- uses: hashicorp/setup-terraform@v1
- name: 'Checkout'
uses: actions/checkout@master
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- uses: EndBug/add-and-commit@v7
with:
message: Terraform fmt [skip ci]
committer_name: GitHub Actions
committer_email: actions@github.com
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Apply
id: apply
run: terraform apply
continue-on-error: true

68
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,68 @@
name: 'Terraform GitHub Actions'
on:
- pull_request
env:
tf_version: 'latest'
tf_working_dir: '.'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
terraform:
environment: main
name: 'Terraform'
runs-on: ubuntu-latest
steps:
- uses: hashicorp/setup-terraform@v1
- name: 'Checkout'
uses: actions/checkout@master
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- uses: EndBug/add-and-commit@v7
with:
message: Terraform fmt [skip ci]
committer_name: GitHub Actions
committer_email: actions@github.com
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
run: terraform plan -no-color -out prod.plan
continue-on-error: true
- uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outputs.stdout }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})

4
cdn.tf
View File

@ -248,7 +248,7 @@ resource "aws_cloudfront_distribution" "sondehub" {
}
ordered_cache_behavior {
allowed_methods = [ "GET", "HEAD"]
allowed_methods = ["GET", "HEAD"]
cached_methods = [
"HEAD",
"GET"
@ -269,7 +269,7 @@ resource "aws_cloudfront_distribution" "sondehub" {
viewer_protocol_policy = "redirect-to-https"
}
ordered_cache_behavior {
allowed_methods = [ "GET", "HEAD", "OPTIONS"]
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = [
"HEAD",
"GET"

View File

@ -3,12 +3,10 @@ terraform {
bucket = "sondehub-terraform"
key = "sondehub-main"
region = "us-east-1"
profile = "sondes"
}
}
provider "aws" {
region = "us-east-1"
profile = "sondes"
}
locals {
@ -126,3 +124,6 @@ resource "aws_acm_certificate" "CertificateManagerCertificate_root" {
]
validation_method = "DNS"
}
resource "aws_s3_bucket" "test123" {
}