forked from TietoEVRY-DataPlatforms/gitops-deploy-tag-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
51 lines (44 loc) · 1.57 KB
/
action.yml
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
name: 'GitOps Deploy Tag Action'
description: 'Updates image tag in target file'
inputs:
gitops-repo:
description: 'gitops repo to be updated'
required: true
default: ${DEPLOY_GITOPS_REPO}
target-file:
description: 'Target yaml file to replace tag'
required: true
docker-image-tag:
description: 'docker image tag'
required: true
default: ${GITHUB_SHA::7}
gitops-branch:
description: 'branch name'
required: false
default: master
runs:
using: "composite"
steps:
- name: Checkout gitops
run: |
echo Checking out ${GITHUB_SERVER_URL}/${{ inputs.gitops-repo }}.git
rm -rf ./gitops_tmp
GH_URL=$(echo "$GITHUB_SERVER_URL" | sed 's,://,://x-access-token:'"$DEPLOY_TOKEN"'@,g')
git clone --depth 1 ${GH_URL}/${{ inputs.gitops-repo }}.git ./gitops_tmp
shell: bash
- name: Update image tag
working-directory: ./gitops_tmp
run: |
echo Setting \"${{ inputs.docker-image-tag }}\" tag in "${{ inputs.target-file }}"
sed -i 's/tag: .*$/tag: "'${{ inputs.docker-image-tag }}'"/g' ${{ inputs.target-file }}
shell: bash
- name: Push changes to gitops
working-directory: ./gitops_tmp
run: |
echo Pushing changes to ${{ inputs.gitops-repo }}
git config user.name "GitHub Actions"
git config user.email "ga-deployer@tietoevry.com"
git add .
git commit --allow-empty -m "Deploy \"${{ inputs.docker-image-tag }}\" tag into ${{ inputs.target-file }}"
git push -u origin ${{ inputs.gitops-branch }}
shell: bash