mirror of
https://github.com/projecthorus/sondehub-infra.git
synced 2025-01-30 15:43:55 +00:00
Add github actions
maybe
This commit is contained in:
parent
831da1cfc3
commit
8196780847
41
.github/workflows/main.yml
vendored
Normal file
41
.github/workflows/main.yml
vendored
Normal 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
68
.github/workflows/pr.yml
vendored
Normal 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
4
cdn.tf
@ -248,7 +248,7 @@ resource "aws_cloudfront_distribution" "sondehub" {
|
|||||||
}
|
}
|
||||||
ordered_cache_behavior {
|
ordered_cache_behavior {
|
||||||
|
|
||||||
allowed_methods = [ "GET", "HEAD"]
|
allowed_methods = ["GET", "HEAD"]
|
||||||
cached_methods = [
|
cached_methods = [
|
||||||
"HEAD",
|
"HEAD",
|
||||||
"GET"
|
"GET"
|
||||||
@ -269,7 +269,7 @@ resource "aws_cloudfront_distribution" "sondehub" {
|
|||||||
viewer_protocol_policy = "redirect-to-https"
|
viewer_protocol_policy = "redirect-to-https"
|
||||||
}
|
}
|
||||||
ordered_cache_behavior {
|
ordered_cache_behavior {
|
||||||
allowed_methods = [ "GET", "HEAD", "OPTIONS"]
|
allowed_methods = ["GET", "HEAD", "OPTIONS"]
|
||||||
cached_methods = [
|
cached_methods = [
|
||||||
"HEAD",
|
"HEAD",
|
||||||
"GET"
|
"GET"
|
||||||
|
5
main.tf
5
main.tf
@ -3,12 +3,10 @@ terraform {
|
|||||||
bucket = "sondehub-terraform"
|
bucket = "sondehub-terraform"
|
||||||
key = "sondehub-main"
|
key = "sondehub-main"
|
||||||
region = "us-east-1"
|
region = "us-east-1"
|
||||||
profile = "sondes"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
provider "aws" {
|
provider "aws" {
|
||||||
region = "us-east-1"
|
region = "us-east-1"
|
||||||
profile = "sondes"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
@ -126,3 +124,6 @@ resource "aws_acm_certificate" "CertificateManagerCertificate_root" {
|
|||||||
]
|
]
|
||||||
validation_method = "DNS"
|
validation_method = "DNS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_s3_bucket" "test123" {
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user