create-space #8
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 | |
github_username: | |
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" | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- name: Create file for space | |
run : | | |
cat > ${{ inputs.github_username }}.software-engineer.space.tf << EOF | |
module "${{ inputs.dns_prefix }}" { | |
source = "./modules/software-engineer-space" | |
github_handle = "${{ inputs.github_username }}" | |
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 ${{ inputs.github_username }}.software-engineer.space.tf | |
git commit -am "Add space for ${{ inputs.github_username }} as ${{ inputs.dns_prefix }}.software-engineer.space.tf" | |
git push | |
- name: Run terraform | |
run: | | |
terraform init | |
terraform apply -auto-approve | |
terraform apply -auto-approve | |
env: | |
TF_VAR_CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
TF_VAR_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |