-
Notifications
You must be signed in to change notification settings - Fork 211
134 lines (117 loc) · 4.28 KB
/
pr-deploy.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# v3.800.4
name: PR deploy
on:
pull_request:
branches: [ master, dev ]
types: [ labeled ]
jobs:
get-deployment-data:
if: ${{ github.event.label.name == 'deploy-qa' }}
runs-on: ubuntu-latest
env:
ARTIFACT_NAME: ${{ github.event.repository.name }}
DOCKER_CACHE_KEY: ''
DOCKER_TAR: 'image.tar'
outputs:
dockerShortKey: ${{ steps.cache-key.outputs.dockerShortKey }}
dockerFullKey: ${{ steps.cache-key.outputs.dockerFullKey }}
packageShortKey: ${{ steps.cache-key.outputs.packageShortKey }}
packageFullKey: ${{ steps.cache-key.outputs.packageFullKey }}
dockerTar: ${{ env.DOCKER_TAR }}
jiraKey: ${{ steps.jiraKey.outputs.qaTaskNumber }}
steps:
- uses: actions/checkout@v4
- name: Get Artifact Version
uses: VirtoCommerce/vc-github-actions/get-image-version@master
id: artifactVer
- name: Get cache key
uses: VirtoCommerce/vc-github-actions/cache-get-key@master
id: cache-key
with:
runnerOs: ${{ runner.os }}
artifactName: ${{ env.ARTIFACT_NAME }}
- name: Gets Jira key from PR body
id: jiraKey
uses: VirtoCommerce/vc-github-actions/pr-body-get-link@master
with:
skipArtifactUrl: 'true'
githubToken: ${{ secrets.REPO_TOKEN }}
publish:
needs:
get-deployment-data
uses: VirtoCommerce/.github/.github/workflows/publish-docker.yml@v3.800.4
with:
fullKey: ${{ needs.get-deployment-data.outputs.dockerFullKey }}
shortKey: '${{ needs.get-deployment-data.outputs.dockerShortKey }}-'
dockerTar: ${{ needs.get-deployment-data.outputs.dockerTar }}
secrets:
envPAT: ${{ secrets.GITHUB_TOKEN }}
dockerUser: ${{ secrets.DOCKER_USERNAME }}
dockerToken: ${{ secrets.DOCKER_TOKEN }}
deploy:
needs:
[publish, get-deployment-data]
uses: VirtoCommerce/.github/.github/workflows/deploy.yml@v3.800.4
with:
argoServer: 'argo.govirto.com'
artifactUrl: ${{ needs.publish.outputs.imagePath }}
matrix: '{"include":[{"envName": "qa", "confPath": ".deployment/storefront-app/argoDeploy.json"}]}'
taskNumber: ${{ needs.get-deployment-data.outputs.jiraKey }}
forceCommit: false
secrets:
envPAT: ${{ secrets.REPO_TOKEN }}
argoLogin: ${{ secrets.ARGOCD_LOGIN }}
argoPassword: ${{ secrets.ARGOCD_PASSWORD }}
comment-publish:
if: ${{ always() && github.event.label.name == 'deploy-qa' }}
needs:
publish
env:
MESSAGE_BODY: ':x: Docker image publish filed.'
runs-on: ubuntu-latest
steps:
- name: Set MESSAGE_BODY
if: ${{ needs.publish.result == 'success' }}
run: |
echo "MESSAGE_BODY=:heavy_check_mark: Docker image ${{ needs.publish.outputs.imagePath }} published" >> $GITHUB_ENV
- name: Add link to PR
if: ${{ needs.publish.result == 'success' }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: VirtoCommerce/vc-github-actions/publish-artifact-link@master
with:
artifactUrl: ${{ needs.publish.outputs.imagePath }}
- uses: actions/github-script@v7
if: ${{ !(contains('skipped, cancelled', needs.publish.result )) }}
with:
#github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '${{ env.MESSAGE_BODY }}'
})
comment-deploy:
if: ${{ always() && github.event.label.name == 'deploy-qa' }}
needs:
[ deploy, publish ]
runs-on: ubuntu-latest
env:
MESSAGE_BODY: ':x: QA deployment failed.'
steps:
- name: Set MESSAGE_BODY
if: ${{ needs.deploy.result == 'success' }}
run: |
echo "MESSAGE_BODY=:heavy_check_mark: Docker image ${{ needs.publish.outputs.imagePath }} deployed to QA" >> $GITHUB_ENV
- uses: actions/github-script@v7
if: ${{ !(contains('skipped, cancelled', needs.deploy.result )) }}
with:
#github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '${{ env.MESSAGE_BODY }}'
})