forked from Sylius/Sylius-Standard
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (71 loc) · 2.77 KB
/
bns-ci.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
name: Bunnyshell CI
concurrency: bns-ci
on:
push:
branches:
- '*.*'
jobs:
deploy:
name: Deploy CI environment
runs-on: ubuntu-latest
outputs:
envId: ${{ env.BNS_ENV_ID }}
appEndpointUrl: ${{ env.APP_ENDPOINT_URL }}
steps:
- name: Prepare vars
run: |-
echo "BNS_ENV_NAME=Sylius CI ${GITHUB_RUN_ID}" >> "$GITHUB_ENV"
- name: Check out the repo
uses: actions/checkout@v2
- name: Get Kubernetes integration
uses: addnab/docker-run-action@v3
with:
image: bunnyshell/cli:latest
options: -v ${{ github.env }}:/github/envs.txt
run: |-
set -ex
echo "CLUSTER_ID=`bns k8s-clusters list --token ${{ secrets.BUNNYSHELL_ACCESS_TOKEN }} --organization ${{ vars.BUNNYSHELL_ORGANIZATION_ID }} --non-interactive -o json | jq -r '._embedded.item[0].id'`" >> /github/envs.txt
- name: Create Environment
uses: addnab/docker-run-action@v3
with:
image: bunnyshell/cli:latest
options: -v ${{ github.workspace }}:/work -v ${{ github.env }}:/github/envs.txt
run: |-
set -ex
echo "BNS_ENV_ID=`bns environments create --name "${{ env.BNS_ENV_NAME }}" --from-path /work/.bunnyshell/templates/prod/bunnyshell.yaml --k8s "${{ env.CLUSTER_ID }}" --token ${{ secrets.BUNNYSHELL_ACCESS_TOKEN }} --project ${{ vars.BUNNYSHELL_PROJECT_ID }} --non-interactive -o json | jq -r '.id'`" >> /github/envs.txt
- name: Deploy Environment
uses: addnab/docker-run-action@v3
with:
image: bunnyshell/cli:latest
options: -v ${{ github.workspace }}:/work -v ${{ github.env }}:/github/envs.txt
run: |-
set -ex
DEPLOY_OUTPUT=`bns environments deploy --id ${{ env.BNS_ENV_ID }} --token ${{ secrets.BUNNYSHELL_ACCESS_TOKEN }} --non-interactive -o json`
echo "APP_ENDPOINT_URL=`echo \"$DEPLOY_OUTPUT\" | grep -A 100 '\[' | jq -r '.[] | select(.name == \"php\") | .endpoints[0]'`" >> /github/envs.txt
test:
name: Run E2E tests
runs-on: ubuntu-latest
needs: deploy
continue-on-error: true
steps:
- name: App tests
run: |-
set -ex
APP_ENDPOINT=${{ needs.deploy.outputs.appEndpointUrl }}
if [ -z "$APP_ENDPOINT" ]; then
echo "No APP_ENDPOINT"
exit 1
fi
curl -s --fail-with-body "$APP_ENDPOINT"
cleanup:
name: Delete CI environment
runs-on: ubuntu-latest
if: "${{ needs.deploy.outputs.envId != '' }}"
needs: [deploy, test]
steps:
- name: Deleting Environment
uses: addnab/docker-run-action@v3
with:
image: bunnyshell/cli:latest
run: |-
bns environments delete --id ${{ needs.deploy.outputs.envId }} --token ${{ secrets.BUNNYSHELL_ACCESS_TOKEN }} --non-interactive