add_domain #62
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: Modify cloudflare.tf | |
on: | |
repository_dispatch: | |
types: [add_domain] | |
jobs: | |
add_ecr: | |
env: | |
TF_IN_AUTOMATION: true | |
TF_CLOUD_ORGANIZATION: "xquare" | |
TF_WORKSPACE: "xquare-global" | |
CONFIG_DIRECTORY: "./" | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
RDS_MASTER_PASSWORD: ${{ secrets.RDS_MASTER_PASSWORD }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_XQUARE_ZONE_ID }} | |
if: ${{ github.event.client_payload.domain }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Add Domain | |
shell: bash | |
run: | | |
echo ${{ github.event.client_payload.domain }} | |
domain_name=$(echo "${{ github.event.client_payload.domain }}" | sed 's/\..*//') | |
location=$(grep -n "# DOMAIN_NAME" cloudflare.tf | cut -d ":" -f 1) | |
if [ -n "$location" ]; then | |
sed -i "${location}s|.*|&\n \"$domain_name\",|" cloudflare.tf | |
fi | |
- 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: [email protected] | |
commit_author: XQUARE GitOps Bot <[email protected]> | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }} |