-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was based on a simple test of an import of an existing Cloudflare pages deployment. It should be enough to replace that import using this module.
- Loading branch information
Showing
9 changed files
with
263 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "fix(dependabot)" | ||
- package-ecosystem: "terraform" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "fix(dependabot)" |
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,41 @@ | ||
--- | ||
name: Tag release | ||
on: | ||
push: | ||
branches: | ||
- '!**' | ||
- 'main' | ||
|
||
jobs: | ||
tag-release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: write | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check for conventional commits | ||
uses: cocogitto/cocogitto-action@v3.8 | ||
- name: Get next version | ||
id: next_version | ||
run: | | ||
echo NEXT_VERSION=`cog bump --auto --dry-run` >> "$GITHUB_ENV" | ||
- name: Cocogitto tag | ||
id: release | ||
uses: cocogitto/cocogitto-action@v3 | ||
with: | ||
check-latest-tag-only: true | ||
release: true | ||
git-user: 'GitHubActions' | ||
git-user-email: 'github@lazzurs.org' | ||
- name: Generate Changelog | ||
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md | ||
- name: Upload github release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
body_path: GITHUB_CHANGELOG.md | ||
tag_name: ${{ steps.release.outputs.version }} |
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,25 @@ | ||
repos: | ||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.96.1 | ||
hooks: | ||
- id: terragrunt_fmt | ||
- id: terragrunt_validate | ||
- id: terragrunt_validate_inputs | ||
- id: terraform_fmt | ||
- id: terraform_docs | ||
args: | ||
- --args=--html=true --anchor=true --lockfile=false | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: forbid-submodules | ||
- id: detect-aws-credentials | ||
args: | ||
- --allow-missing-credentials | ||
- id: detect-private-key | ||
- id: check-case-conflict | ||
- id: check-yaml | ||
- id: sort-simple-yaml |
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 |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# terraform-cloudflare-pages-github | ||
Terraform module for terraform-cloudflare-pages-github | ||
|
||
Simple Terraform module to deploy a static site to Cloudflare Pages from a GitHub repository. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_cloudflare"></a> [cloudflare](#requirement\_cloudflare) | 4.45.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | 4.45.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [cloudflare_pages_project.this](https://registry.terraform.io/providers/cloudflare/cloudflare/4.45.0/docs/resources/pages_project) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_build_command"></a> [build\_command](#input\_build\_command) | Command to build the project | `string` | n/a | yes | | ||
| <a name="input_cloudflare_account_id"></a> [cloudflare\_account\_id](#input\_cloudflare\_account\_id) | Cloudflare account ID | `string` | n/a | yes | | ||
| <a name="input_destination_dir"></a> [destination\_dir](#input\_destination\_dir) | Directory where the build command outputs the files | `string` | n/a | yes | | ||
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | Owner of the GitHub repository | `string` | n/a | yes | | ||
| <a name="input_github_repo_name"></a> [github\_repo\_name](#input\_github\_repo\_name) | Name of the GitHub repository | `string` | n/a | yes | | ||
| <a name="input_preview_environment_variables"></a> [preview\_environment\_variables](#input\_preview\_environment\_variables) | Environment variables for the preview environment | `map(string)` | n/a | yes | | ||
| <a name="input_production_branch"></a> [production\_branch](#input\_production\_branch) | Name of the production branch | `string` | n/a | yes | | ||
| <a name="input_production_environment_variables"></a> [production\_environment\_variables](#input\_production\_environment\_variables) | Environment variables for the production environment | `map(string)` | n/a | yes | | ||
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Name of the project | `string` | n/a | yes | | ||
| <a name="input_root_dir"></a> [root\_dir](#input\_root\_dir) | Root directory of the project | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
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,25 @@ | ||
from_latest_tag = true | ||
ignore_merge_commits = true | ||
disable_changelog = false | ||
disable_bump_commit = false | ||
branch_whitelist = [] | ||
skip_ci = "[skip ci]" | ||
skip_untracked = false | ||
pre_bump_hooks = [] | ||
post_bump_hooks = [ | ||
"git push", | ||
"git push origin --tags" | ||
] | ||
pre_package_bump_hooks = [] | ||
post_package_bump_hooks = [] | ||
monorepo_version_separator = "/" | ||
tag_prefix = "v" | ||
|
||
[git_hooks] | ||
|
||
[commit_types] | ||
chore = { changelog_title = "Chores" } | ||
|
||
[changelog] | ||
path = "CHANGELOG.md" | ||
authors = [] |
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,54 @@ | ||
resource "cloudflare_pages_project" "this" { | ||
account_id = var.cloudflare_account_id | ||
name = var.project_name | ||
production_branch = var.production_branch | ||
build_config { | ||
build_caching = false | ||
build_command = var.build_command | ||
destination_dir = var.destination_dir | ||
root_dir = var.root_dir | ||
} | ||
deployment_configs { | ||
preview { | ||
always_use_latest_compatibility_date = false | ||
compatibility_date = "2024-10-27" | ||
compatibility_flags = [] | ||
d1_databases = {} | ||
durable_object_namespaces = {} | ||
environment_variables = var.preview_environment_variables | ||
fail_open = true | ||
kv_namespaces = {} | ||
r2_buckets = {} | ||
usage_model = "standard" | ||
} | ||
production { | ||
always_use_latest_compatibility_date = false | ||
compatibility_date = "2024-10-27" | ||
compatibility_flags = [] | ||
d1_databases = {} | ||
durable_object_namespaces = {} | ||
environment_variables = var.production_environment_variables | ||
fail_open = true | ||
kv_namespaces = {} | ||
r2_buckets = {} | ||
usage_model = "standard" | ||
} | ||
} | ||
source { | ||
type = "github" | ||
|
||
config { | ||
deployments_enabled = true | ||
owner = var.github_owner | ||
pr_comments_enabled = true | ||
preview_branch_excludes = [] | ||
preview_branch_includes = [ | ||
"*", | ||
] | ||
preview_deployment_setting = "all" | ||
production_branch = var.production_branch | ||
production_deployment_enabled = true | ||
repo_name = var.github_repo_name | ||
} | ||
} | ||
} |
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 @@ | ||
provider "cloudflare" {} |
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,49 @@ | ||
variable "cloudflare_account_id" { | ||
description = "Cloudflare account ID" | ||
type = string | ||
} | ||
|
||
variable "project_name" { | ||
description = "Name of the project" | ||
type = string | ||
} | ||
|
||
variable "production_branch" { | ||
description = "Name of the production branch" | ||
type = string | ||
} | ||
|
||
variable "build_command" { | ||
description = "Command to build the project" | ||
type = string | ||
} | ||
|
||
variable "destination_dir" { | ||
description = "Directory where the build command outputs the files" | ||
type = string | ||
} | ||
|
||
variable "root_dir" { | ||
description = "Root directory of the project" | ||
type = string | ||
} | ||
|
||
variable "preview_environment_variables" { | ||
description = "Environment variables for the preview environment" | ||
type = map(string) | ||
} | ||
|
||
variable "production_environment_variables" { | ||
description = "Environment variables for the production environment" | ||
type = map(string) | ||
} | ||
|
||
variable "github_owner" { | ||
description = "Owner of the GitHub repository" | ||
type = string | ||
} | ||
|
||
variable "github_repo_name" { | ||
description = "Name of the GitHub repository" | ||
type = string | ||
} |
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,8 @@ | ||
terraform { | ||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = "4.45.0" | ||
} | ||
} | ||
} |