-
Notifications
You must be signed in to change notification settings - Fork 45
147 lines (122 loc) · 5.36 KB
/
midaz-update-repos.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
135
136
137
138
139
140
141
142
143
144
145
146
147
name: "Midaz Update Submodule on midaz-stack and Swagger on Git Pages"
on:
push:
branches:
- main
tags-ignore:
- '**'
jobs:
update-submodule-on-midaz-stack:
name: Run Update midaz submodule on midaz-stack
runs-on: ubuntu-24.04
steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
passphrase: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
git_committer_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
git_committer_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Pull midaz-stack and submodules
uses: actions/checkout@v4
with:
repository: LerianStudio/midaz-stack
ref: main
path: midaz-stack
submodules: recursive
token: ${{ secrets.MANAGE_TOKEN }}
- name: Push midaz-stack and midaz submodule
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.MANAGE_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
run: |
cd midaz-stack
cd midaz
git checkout main
git pull origin main
cd ..
git add midaz
git commit -S -m "Updating the submodule 'midaz' to the latest version"
git push origin main
update-swagger-on-pages:
name: Run Update swagger on ledger and transaction in LerianStudio.github.io
runs-on: ubuntu-24.04
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
passphrase: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
git_committer_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
git_committer_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Install GitHub CLI
run: sudo apt-get install -y gh
- name: Get MIDAZ and Pages
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.MANAGE_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
run: |
gh repo clone LerianStudio/midaz
gh repo clone LerianStudio/LerianStudio.github.io
- name: Generate Swagger on Ledger and Transaction
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cd midaz
export PATH=$PATH:/usr/local/go/bin:$(go env GOPATH)/bin
go install github.com/swaggo/swag/cmd/swag@latest
swag --version
make tidy
make generate-docs-all
cd ..
- name: Copy openapi.yaml and swagger.json to Repos to LerianStudio.github.io
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cp midaz/components/audit/api/swagger.json LerianStudio.github.io/audit/
cp midaz/components/audit/api/openapi.yaml LerianStudio.github.io/audit/
cp midaz/components/ledger/api/swagger.json LerianStudio.github.io/ledger/
cp midaz/components/ledger/api/openapi.yaml LerianStudio.github.io/ledger/
cp midaz/components/transaction/api/swagger.json LerianStudio.github.io/transaction/
cp midaz/components/transaction/api/openapi.yaml LerianStudio.github.io/transaction/
- name: Commit and Push Swagger to Git Page
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.MANAGE_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
run: |
cd LerianStudio.github.io
if git status --porcelain | grep -qE "^[ MADRCU]"; then
echo "Changes detected!"
git remote set-url origin https://${{ secrets.MANAGE_TOKEN }}@github.com/LerianStudio/LerianStudio.github.io.git
git add audit ledger transaction
git commit -S -m "Update openapi.yaml and swagger.json from Repositories"
git push origin main
else
echo "No changes detected."
exit 0
fi