diff --git a/.github/workflows/add_domain.yaml b/.github/workflows/add_domain.yaml index 6dd5e7c..8a86f05 100644 --- a/.github/workflows/add_domain.yaml +++ b/.github/workflows/add_domain.yaml @@ -24,7 +24,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Add ecr + - name: Add Domain shell: bash run: | echo ${{ github.event.client_payload.domain }} @@ -33,21 +33,6 @@ jobs: if [ -n "$location" ]; then sed -i "${location}s|.*|&\n \"$domain_name\",|" cloudflare.tf fi - - - name: Commit with new ECR - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "πŸ”€ :: domain [${{ github.event.client_payload.domain }}] μΆ”κ°€" - branch: main - file_pattern: 'cloudflare.tf' - push_options: '--force' - commit_options: '--no-verify --signoff' - repository: . - commit_user_name: XQUARE GitOps Bot - commit_user_email: teamxquare@gmail.com - commit_author: XQUARE GitOps Bot - env: - GITHUB_TOKEN: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }} - name: Set up Terraform uses: hashicorp/setup-terraform@v1 @@ -67,7 +52,22 @@ jobs: json_result=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/dns_records?type=CNAME&name=${{ github.event.client_payload.domain }}" \ -H "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}") id=$(echo "$json_result" | jq -r '.result[0].id') - + + domain_name=$(echo "${{ github.event.client_payload.domain }}" | sed 's/\..*//') terraform import -lock=false -var 'cloudflare_api_token=${{ env.CLOUDFLARE_API_TOKEN }}' \ - cloudflare_record.xquare_server_record[\"${{ github.event.client_payload.domain }}\"] ${{ env.CLOUDFLARE_ZONE_ID }}/$id + cloudflare_record.xquare_server_record[\"$domain_name\"] ${{ env.CLOUDFLARE_ZONE_ID }}/$id + - name: Commit with new Domain + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "πŸ”€ :: domain [${{ github.event.client_payload.domain }}] μΆ”κ°€" + branch: main + file_pattern: 'cloudflare.tf' + push_options: '--force' + commit_options: '--no-verify --signoff' + repository: . + commit_user_name: XQUARE GitOps Bot + commit_user_email: teamxquare@gmail.com + commit_author: XQUARE GitOps Bot + env: + GITHUB_TOKEN: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }}