-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (55 loc) · 2.25 KB
/
add_ecr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Modify ecr.tf
on:
repository_dispatch:
types: [add_ecr]
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 }}
if: ${{ github.event.client_payload.repository_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Add ecr
shell: bash
run: |
location=$(grep -n "# ECR_REPOSITORY_NAME" ecr.tf | cut -d ":" -f 1)
if [ -n "$location" ]; then
sed -i "${location}s|.*|&\n \"${{ github.event.client_payload.repository_name }}\",|" ecr.tf
fi
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform init
shell: bash
run: terraform init
- name: Terraform import
if: ${{ github.event.client_payload.environment }} == 'prod' || ${{ github.event.client_payload.environment }} == 'stag'
shell: bash
run: |
terraform import -var 'cloudflare_api_token=${{ env.CLOUDFLARE_API_TOKEN }}' \
'module.${{ github.event.client_payload.environment }}_ecr["${{ github.event.client_payload.repository_name }}"].aws_ecr_repository.repo' \
${{ github.event.client_payload.repository_name }}
- name: Commit with new ECR
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "🔀 :: ecr repository [${{ github.event.client_payload.repository_name }}] 추가"
branch: main
file_pattern: 'ecr.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 <teamxquare@gmail.com>
env:
GITHUB_TOKEN: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }}