generated from cloudposse-github-actions/composite-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
150 lines (135 loc) · 5 KB
/
test-positive.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
148
149
150
name: Test example positive
on:
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered
# #
# # Added pull_request to register workflow from the PR.
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
# pull_request: {}
workflow_dispatch: {}
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
run: echo "Do setup"
test:
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup]
services:
localstack:
image: localstack/localstack:1.4.0
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
ports:
- 4566:4566
- 4510-4559:4510-4559
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Docker network
id: docker-context
run: |
NETWORK_NAME=$(docker network ls --filter='name=github_network_*' --format "{{.Name}}")
echo "network=${NETWORK_NAME}" >> $GITHUB_OUTPUT
- name: "Create K8S Cluster"
uses: AbsaOSS/k3d-action@v2
id: k3s
with:
cluster-name: "default"
args: >-
-p "8083:80@agent:0:direct"
-p "8443:443@agent:0:direct"
-p "5053:53/udp@agent:0:direct"
-p "6443:6443@server:0:direct"
--agents 1
--no-lb
--network "${{ steps.docker-context.outputs.network }}"
--image docker.io/rancher/k3s:v1.23.2-k3s1
- name: Export kubeconfig
id: kubeconfig
run: |
mkdir -p ${RUNNER_TEMP}/_github_home
cp ~/.kube/config ${RUNNER_TEMP}/_github_home/kubeconfig
echo "path=/github/home/kubeconfig" >> $GITHUB_OUTPUT
- name: Update kubeconfig to work in docker network
uses: mikefarah/[email protected]
with:
cmd: yq -i '.clusters[0].cluster.server = "https://k3d-default-server-0:6443"' '/github/home/kubeconfig'
- name: 'Install jq 1.6'
uses: dcarbone/[email protected]
with:
version: 1.6
force: 'true'
- name: Mock platform context
run: |
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/staging/default_ingress_domain" \
--type "SecureString" \
--value "example.com"
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/staging/default_alb_ingress_group" \
--type "SecureString" \
--value "default"
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/_metadata/kube_version" \
--type "SecureString" \
--value "1.15"
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
## Use localhost to connect localstack because the commands runs not in a container
AWS_ENDPOINT_OVERRIDE: http://localhost:4566
- name: Mock AWS command
id: mock
run: |
mkdir -p ${RUNNER_TEMP}/_github_home/bin/
echo "exit 0;" >> ${RUNNER_TEMP}/_github_home/bin/aws
chmod +x ${RUNNER_TEMP}/_github_home/bin/aws
cat ${RUNNER_TEMP}/_github_home/bin/aws
echo "path=/github/home/bin/:${RUNNER_TEMP}/bin/:${PATH}" >> $GITHUB_OUTPUT
- uses: ./
id: current
with:
helmfile-path: ./test
aws-region: us-east-1
cluster: default
environment: staging
namespace: staging
image: nginx
image-tag: latest
operation: deploy
debug: false
helm_version: 3.11.0
helmfile_version: 0.143.4
kubectl_version: 1.26.2
chamber_version: 2.10.1
env:
PATH_OVERRIDE: ${{ steps.mock.outputs.path }}
KUBECONFIG: ${{ steps.kubeconfig.outputs.path }}
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
## Use localhost to connect localstack because the commands runs not in a container
AWS_ENDPOINT_OVERRIDE: http://localstack:4566
## Use localstack to connect localstack because the chamber runs in a container
CHAMBER_AWS_SSM_ENDPOINT: http://localstack:4566/
outputs:
result: "${{ steps.current.outputs.webapp-url }}"
assert:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: nick-fields/assert-action@v2
with:
expected: 'https://example-app.example.com/dashboard'
actual: "${{ needs.test.outputs.result }}"
teardown:
runs-on: ubuntu-latest
needs: [assert]
if: ${{ always() }}
steps:
- name: Tear down
run: echo "Do Tear down"