Skip to content

Commit

Permalink
Merge pull request #1792 from matter-labs/devops/ci-dispatch-update
Browse files Browse the repository at this point in the history
[ci] add update config workflow
  • Loading branch information
dennybaa authored Jul 27, 2021
2 parents 4c1249b + d9c41f3 commit 4d900a1
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/update-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Update Config
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment where to update the config'
required: true
ref:
description: 'Branch or tag to fetch configs from'
required: true

defaults:
run:
shell: bash -leo pipefail {0}

jobs:
pre:
runs-on: [k8s, stage]
steps:
- uses: actions/checkout@v2
-
id: config
run: |
environment=${{ github.event.inputs.environment }}
ref=${{ github.event.inputs.ref }}
echo "::set-output name=environment::${environment}"
echo "::set-output name=ref::${ref}"
-
uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ steps.config.outputs.ref }}
regex: '^refs\/tags\/((v[0-9]+\.[0-9]+\.[0-9])(-?.*)?)$'
-
name: Map runtime environment data
id: envMap
uses: kanga333/[email protected]
with:
key: ${{ steps.config.outputs.environment }}
export_to: output
mode: overwrite
map: |
{
".*": {
"hfEnv": "${{ steps.config.outputs.environment }}",
"kubeConf": "KUBECONF_STAGE",
"runner": "stage",
"namespace": "${{ steps.config.outputs.environment }}"
},
"^rinkeby$": { "kubeConf": "KUBECONF_TESTNET", "runner": "testnet" },
"^ropsten$": { "kubeConf": "KUBECONF_TESTNET", "runner": "testnet" },
"^mainnet$": { "kubeConf": "KUBECONF_MAINNET", "runner": "mainnet", "hfEnv": "prod", "namespace": "zksync" }
}
outputs:
environment: ${{ steps.config.outputs.environment }}
kubeConf: ${{ steps.envMap.outputs.kubeConf }}
hfEnv: ${{ steps.envMap.outputs.hfEnv }}
namespace: ${{ steps.envMap.outputs.namespace }}
runner: ${{ steps.envMap.outputs.runner }}
configTag: ${{ steps.config.outputs.ref }}
isTag: ${{ steps.regex-match.outputs.group1 != '' }}

updateConfig:
if: ${{ needs.pre.outputs.isTag == 'true' }}
name: update config
needs: [pre]
runs-on: [k8s, deployer, "${{ needs.pre.outputs.runner }}"]
container:
image: dysnix/kubectl:v1.19-gcloud
env:
KUBECONF: ${{ secrets[needs.pre.outputs.kubeConf] }}
ENVFILE: ./compiled_envs/${{ needs.pre.outputs.environment }}.env
steps:
-
name: Create ~/.kube/config
run: mkdir -p ~/.kube && echo "$KUBECONF" | base64 -d > ~/.kube/config
-
name: Clone configs
uses: actions/checkout@v2
with:
repository: matter-labs/configs
path: configs
ref: ${{ needs.pre.outputs.configTag }}
token: ${{ secrets.GH_TOKEN }}
-
name: Update Server Config
working-directory: configs
run: |
sudo apk --no-cache add yarn
./bin/config
./bin/config compile ${{ needs.pre.outputs.environment }}
kubectl delete configmap -n ${{ needs.pre.outputs.namespace }} server-env-custom || /bin/true
kubectl create configmap -n ${{ needs.pre.outputs.namespace }} server-env-custom --from-env-file=${{ env.ENVFILE }}
# kubectl delete pod -n ${{ needs.pre.outputs.namespace }} -l app.kubernetes.io/instance=server

0 comments on commit 4d900a1

Please sign in to comment.