-
Notifications
You must be signed in to change notification settings - Fork 7
86 lines (70 loc) · 3.3 KB
/
update-stack.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
name: Update Stack Repo
on:
repository_dispatch:
types:
- UpdateStackRepo
jobs:
update_stack_repo:
name: Update Stack Repo
runs-on: ubuntu-latest
env:
SERVICE_NAME: ${{ github.event.client_payload.stackEntry.name }}
SERVICE_VERSION: ${{ github.event.client_payload.stackEntry.details.image.tag }}
STACK_PATH: ${{ github.event.client_payload.stackPath }}
STACK_FILE: ${{ github.event.client_payload.stackFile }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.branch }}
- name: Create yq Query
id: create_yq_query
env:
SERVICE_UPDATE: ${{ toJson(github.event.client_payload.stackEntry.details) }}
run: |
echo "Updating stack repo entry for ${SERVICE_NAME}"
echo "Update is:"
echo ${SERVICE_UPDATE} | json_pp
echo "Current stack is:"
cat stack.yml
SERVICE_QUERY="(.$STACK_PATH.$SERVICE_NAME)"
echo ::set-output name=query::"$SERVICE_QUERY = ${SERVICE_UPDATE//$'\n'/} | sortKeys(..)"
- name: Update Stack File
uses: mikefarah/yq@v4.6.1
with:
cmd: yq eval -i '${{ steps.create_yq_query.outputs.query }}' $STACK_FILE
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3.8.2
env:
SERVICE_ORG: ${{ github.event.client_payload.stackEntry.details.vcs.repo.orgName }}
SERVICE_REPO: ${{ github.event.client_payload.stackEntry.details.vcs.repo.repoName }}
SERVICE_SHA: ${{ github.event.client_payload.stackEntry.details.vcs.sha }}
BASE_SERVICE_ORG: ${{ github.event.client_payload.stackEntry.baseVcs.repo.orgName }}
BASE_SERVICE_REPO: ${{ github.event.client_payload.stackEntry.baseVcs.repo.repoName }}
BASE_SERVICE_SHA: ${{ github.event.client_payload.stackEntry.baseVcs.sha }}
RELEASE_BRANCH: ${{ github.event.client_payload.branch }}
SERVICE_IMAGE_REPOSITORY: ${{ github.event.client_payload.stackEntry.details.image.repository }}
with:
token: ${{ secrets.ASTROLABE_GITHUB_TOKEN }}
commit-message: "chore(cd): update ${{ env.SERVICE_NAME}} version to ${{ env.SERVICE_VERSION}}"
branch: ${{ env.SERVICE_NAME}}_${{ env.SERVICE_VERSION}}
branch-suffix: timestamp
title: "chore(cd): update ${{ env.SERVICE_NAME}} version to ${{ env.SERVICE_VERSION}}"
labels: |
autoMerge
stackUpdate
${{ github.event.client_payload.stackEntry.name }}
body: |
## Promotion Of New ${{ env.SERVICE_NAME}} Version
### Release Branch
* **${{ env.RELEASE_BRANCH}}**
### ${{ env.SERVICE_NAME}} Image Version
${{ env.SERVICE_IMAGE_REPOSITORY}}:${{ env.SERVICE_VERSION}}
### Service VCS
[${{ env.SERVICE_SHA}}](https://github.com/${{ env.SERVICE_ORG}}/${{ env.SERVICE_REPO}}/commit/${{ env.SERVICE_SHA}})
### Base Service VCS
[${{ env.BASE_SERVICE_SHA}}](https://github.com/${{ env.BASE_SERVICE_ORG}}/${{ env.BASE_SERVICE_REPO}}/commit/${{ env.BASE_SERVICE_SHA}})
Event Payload
```
${{ toJson(github.event.client_payload) }}
```