create-space #5
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
name: create-space | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dns_prefix: | ||
required: true | ||
type: string | ||
jobs: | ||
create-space: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: "1.4.7" | ||
- name: Create file for space | ||
run : | | ||
cat > ${{ github.actor }}.software-engineer.space.tf << EOF | ||
module "${{ inputs.dns_prefix }}" { | ||
source = "./modules/software-engineer-space" | ||
github_handle = "${{ github.actor }}" | ||
domain_prefix = "${{ inputs.dns_prefix }}" | ||
cloudflare_zone_id = cloudflare_zone.software-engineer-space.id | ||
providers = { | ||
cloudflare = cloudflare | ||
github = github | ||
} | ||
} | ||
EOF | ||
- name: Commit the new file for space | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add ${{ github.actor }}.software-engineer.space.tf | ||
git commit -am "Add space for ${{ github.actor }} as ${{ inputs.dns_prefix }}.software-engineer.space.tf" | ||
git push | ||
- name: Run terraform | ||
run: | | ||
terraform init | ||
terraform apply -auto-approve | ||
terraform apply -auto-approve | ||
with: | ||
TF_VAR_CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
TF_VAR_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |