-
Notifications
You must be signed in to change notification settings - Fork 45
63 lines (54 loc) · 2.3 KB
/
reusable-deploy-kusama.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
name: Deploy mangata-node to `kusama`
on:
workflow_dispatch:
inputs:
version:
description: "Version to be assigned to the built image"
required: true
type: string
workflow_call:
inputs:
version:
description: "Version to be assigned to the built image"
required: true
type: string
concurrency: kusama_environment
jobs:
deploy_kusama:
runs-on: ubuntu-latest
environment: kusama
env:
version_file: helmfiles/kusama/.version
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
steps:
- name: Verify specified version exists
run: docker pull mangatasolutions/mangata-node:${{ inputs.version }}
- name: Checkout `mangata-finance/gitops` repository
uses: actions/checkout@v3
with:
repository: mangata-finance/gitops
ref: main
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: Push updated version to `gitops` repository
id: version
run: |
echo -n '${{ inputs.version }}' > ${{ env.version_file }}
git config user.name mangatafinance
git config user.email solutions@mangata.finance
git add .
git commit -m 'chore: deploy ${{ inputs.version }} to kusama environment' || \
echo "changed=false" >> $GITHUB_OUTPUT
git push
- name: Watch deployment workflow run
run: |
# Rerun previous workflow if version didn't change
[ -n '${{ steps.version.outputs.changed }}' ] && gh run rerun $(gh run list -w deploy-kusama.yml -L1 --json databaseId --jq '.[].databaseId')
sleep 5 && gh run list -L10 -w deploy-kusama.yml
export RUN_ID=$(gh run list -w deploy-kusama.yml -L1 --json databaseId --jq '.[].databaseId')
if [[ ($(gh run view "$RUN_ID" --json headSha --jq '.headSha') != $(git rev-parse HEAD)) && -z '${{ steps.version.outputs.changed }}' ]]; then
echo "Commited git SHA doesn't match with the SHA of the retrieved Run ID"
exit 1
fi
echo "Deployed version: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Deployment workflow URL: $(gh run view "$RUN_ID" --json url --jq '.url')" >> $GITHUB_STEP_SUMMARY
gh run watch "$RUN_ID" --exit-status