-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (83 loc) · 3.24 KB
/
main.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
on: [push]
jobs:
main:
name: Format & Deploy(master)
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v1
- name: Use Node.js 18.x
uses: actions/setup-node@v2.2.0
with:
node-version: "18.x"
- name: Install
run: yarn
- name: format
run: yarn format
- name: Check formatting
run: git diff --exit-code
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: "latest"
- name: AWS Configure
uses: aws-actions/configure-aws-credentials@v1.6.1
with:
aws-region: ap-southeast-2
mask-aws-account-id: true
role-to-assume: ${{ secrets.AWS_CI_ROLE }}
- name: Login to EKS
run: |
aws eks update-kubeconfig --name Workflow --region ap-southeast-2 --role-arn ${{ secrets.AWS_EKS_ROLE }}
- name: Check EKS connection
run: |
kubectl get nodes
- name: Install Argo
run: |
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.4.0-rc2/argo-linux-amd64.gz
gunzip argo-linux-amd64.gz
chmod +x argo-linux-amd64
./argo-linux-amd64 version
- name: Lint workflows
if: github.ref != 'refs/heads/master'
run: |
# Create test namespace
TEST_NAMESPACE=$GITHUB_SHA
kubectl create namespace $TEST_NAMESPACE
# Create copy of Workflows files to change their namespaces
mkdir test
cp workflows/ test/workflows/ -r
# Deploy templates in the test namespace
# Note: the templates have no default namespace so no need to modify them
kubectl apply -f templates/argo-tasks/ --namespace $TEST_NAMESPACE
# Find all workflows that have kind "WorkflowTemplate"
WORKFLOWS=$(grep '^kind: WorkflowTemplate$' -R test/workflows/ -H | cut -d ':' -f1)
# For each workflow attempt to deploy it using kubectl
for wf in $WORKFLOWS; do
# Change namespace in files
sed -i "/^\([[:space:]]*namespace: \).*/s//\1$TEST_NAMESPACE/" $wf
kubectl apply -f $wf --namespace $TEST_NAMESPACE
done
# TODO May need to deploy config files too?
# Finally lint the templates
./argo-linux-amd64 lint templates/ -n $TEST_NAMESPACE
./argo-linux-amd64 lint test/workflows/ -n $TEST_NAMESPACE
# Delete the test namespace
kubectl delete namespaces $TEST_NAMESPACE
- name: Deploy workflows
if: github.ref == 'refs/heads/master'
run: |
# Deploy templates first
kubectl apply -f templates/argo-tasks/ --namespace argo
# Find all workflows that have kind "WorkflowTemplate"
WORKFLOWS=$(grep '^kind: WorkflowTemplate$' -R workflows/ -H | cut -d ':' -f1)
# For each workflow attempt to deploy it using kubectl
for wf in $WORKFLOWS; do
kubectl apply -f $wf --namespace argo
done
- name: Deploy config files
if: github.ref == 'refs/heads/master'
run: |
kubectl apply -f config/*.yml --namespace argo