generated from dialectlabs/monitoring-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (60 loc) · 2.24 KB
/
cd.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
name: CD
on:
workflow_call:
inputs:
environment:
required: true
type: string
service_name:
required: true
type: string
service_image_tag:
required: true
type: string
secrets:
api_github_token:
required: true
env:
DEPLOYMENT_SCRIPTS_REPO: dialectlabs/infrastructure
jobs:
deployment:
name: Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout deployment repo
uses: actions/checkout@v3
with:
repository: ${{ env.DEPLOYMENT_SCRIPTS_REPO }}
token: ${{ secrets.api_github_token }}
path: ${{ env.DEPLOYMENT_SCRIPTS_REPO }}
- name: Set service name
id: service-name
run: |
echo "::set-output name=service_name::$(echo ${{ inputs.service_name }} | sed s/-/_/g)"
- name: Install hcledit
run: |
curl -L https://github.com/minamijoyo/hcledit/releases/download/v0.2.5/hcledit_0.2.5_linux_amd64.tar.gz | tar -xz
chmod +x ./hcledit
- name: Create version file
id: create-version-file
env:
ENVIRONMENT_DIR: "terraform-plans/environments/${{ inputs.environment }}"
SERVICE_RESOURCES_FILE: "terraform-plans/environments/${{ inputs.environment }}/svc-${{ inputs.service_name }}.tf"
run: |
mkdir -p ${{ env.ENVIRONMENT_DIR }}
cat ${{ env.DEPLOYMENT_SCRIPTS_REPO }}/${{ env.SERVICE_RESOURCES_FILE }} |\
./hcledit attribute set locals.svc_${{ steps.service-name.outputs.service_name }}_image_version '"${{ inputs.service_image_tag }}"' \
> ${{ env.SERVICE_RESOURCES_FILE }}
- name: Create pull request
uses: paygoc6/[email protected]
env:
API_TOKEN_GITHUB: ${{ secrets.api_github_token }}
with:
source_folder: "terraform-plans"
destination_repo: ${{ env.DEPLOYMENT_SCRIPTS_REPO }}
destination_base_branch: 'main'
destination_head_branch: cd/${{ inputs.environment }}/${{ github.event.repository.name }}/${{ inputs.service_image_tag }}
user_email: ${{ github.event.pusher.email }}
user_name: ${{ github.actor }}