-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (48 loc) · 1.52 KB
/
deploy.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
name: GitOps Deploy 🏗️
on:
workflow_call:
inputs:
tag:
description: "Set Docker Image Tag"
required: true
type: string
repository:
description: "Set Repository Name"
required: true
type: string
url:
description: "Set Project URL"
required: true
type: string
environment:
description: "Set Project Environment"
required: true
type: string
jobs:
deploy:
name: GitOps Deploy 🏗️
runs-on: ubuntu-latest
environment:
name: '${{ inputs.environment }}'
url: '${{ inputs.url }}'
steps:
- name: Set Kustomize 🛠️
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: "3.9.4"
- name: GitOps Checkout 🛎️
run: git clone https://${REPO_TOKEN}@github.com/devxp-tech/gitops.git .
env:
REPO_TOKEN: ${{secrets.ACCESS_TOKEN_GITHUB}}
- name: Update Docker Image Tag 🏷️
run: |
cd apps/${{ inputs.repository }}/overlays/dev
OLD_TAG=$(cat kustomization.yaml | grep 'tag:' | awk '{print $2}')
NEW_TAG=${{ inputs.tag }}
sed -i "s|$OLD_TAG|$NEW_TAG|g" kustomization.yaml
- name: Commit and Push 🚀
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "[ci skip] :robot: Set New Image Tag to https://github.com/${{ github.repository }}/commit/${{ inputs.tag }}"
git push