-
Notifications
You must be signed in to change notification settings - Fork 13
87 lines (75 loc) · 2.51 KB
/
pull-request.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
name: On Pull Request
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.build.outputs.image_name }}
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/build
name: Build image
id: build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/test
name: Run tests
deploy_dev:
runs-on: ubuntu-latest
environment: preview
needs: build
container:
image: qwolphin/kdsl:1.21.8
strategy:
fail-fast: false
matrix:
CHAIN_ID: ["1", "137", "43114"]
steps:
- uses: actions/checkout@v2
- name: Set k8s namespace
shell: bash
run: |
echo -e "NAMESPACE=cache-${NS_SUFFIX,,}\nENV_NAME=${{ github.head_ref }}" | tr -c '[:alnum:]-=\n_' '-' >> ${GITHUB_ENV}
env:
NS_SUFFIX: "${{ github.head_ref }}-${{ matrix.CHAIN_ID }}"
- name: Render kdsl resources into yaml
env:
MAINNET_RPC: "${{ secrets.MAINNET_RPC }}"
POLYGON_RPC: "${{ secrets.POLYGON_RPC }}"
RECIPE: "chain${{ matrix.CHAIN_ID }}"
DOMAIN: "${{ env.NAMESPACE }}.aaw.fi"
CHAIN_ID: "${{ matrix.CHAIN_ID }}"
IMAGE: "${{ needs.build.outputs.image_name }}"
COMMIT_SHA: "${{ github.sha }}"
run: |
cd k8s/
python3 main.py > ../rendered.yml
- name: Set up kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.DEV_KUBECONFIG }}" > ~/.kube/config
kubectl config set-context --current --namespace="${{ env.NAMESPACE }}"
- name: Apply k8s resources
shell: bash
run: |
kubectl apply -f rendered.yml
sleep 3
kubectl wait --for condition=ready --timeout 90s pods -l "commit_sha=${{ github.sha }}" || \
{ kubectl get pods && exit 1; }
- uses: actions/github-script@v5
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.payload.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Preview link for chain ${{ matrix.CHAIN_ID }}: https://${{ env.NAMESPACE }}.aaw.fi/'
})