|
| 1 | +name: e2e-k3s |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + e2e-k3s: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + if: ${{ github.event.label.name == 'ok-to-test' }} |
| 12 | + env: |
| 13 | + DOCKER_TAG: pull-${{ github.event.number }} |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v2 |
| 17 | + |
| 18 | + - name: Build Docker image |
| 19 | + run: docker build -t coolboi567/todo-flaskapp:$DOCKER_TAG . |
| 20 | + |
| 21 | + - name: Create a k3s cluster |
| 22 | + uses: AbsaOSS/k3d-action@v2 |
| 23 | + with: |
| 24 | + cluster-name: "flaskapp" |
| 25 | + |
| 26 | + - name: Inject the images to the cluster |
| 27 | + run: k3d image import coolboi567/todo-flaskapp:$DOCKER_TAG -c flaskapp |
| 28 | + |
| 29 | + - name: Deploy the FlaskApp |
| 30 | + run: | |
| 31 | + # create flaskapp namespace |
| 32 | + kubectl create ns flaskapp |
| 33 | + |
| 34 | + # installing FlaskApp using helm |
| 35 | + helm install my-release -n flaskapp ./helm \ |
| 36 | + --wait \ |
| 37 | + --timeout 10m0s \ |
| 38 | + --set flaskapp.service.type=LoadBalancer \ |
| 39 | + --set flaskapp.image.tag=$DOCKER_TAG |
| 40 | + |
| 41 | + # get pods, services and the container images |
| 42 | + kubectl get pods -n flaskapp |
| 43 | + kubectl get svc -n flaskapp |
| 44 | +
|
| 45 | + - name: Get short commit SHA and display tunnel URL |
| 46 | + id: get-subdomain |
| 47 | + run: | |
| 48 | + subdomain="todo-flaskapp-k3s-$(git rev-parse --short HEAD)" |
| 49 | + echo "URL for tunnelling: http://$subdomain.loca.lt" |
| 50 | + echo "::set-output name=subdomain::$subdomain" |
| 51 | +
|
| 52 | + - name: Start tunnel |
| 53 | + env: |
| 54 | + SUBDOMAIN: ${{ steps.get-subdomain.outputs.subdomain }} |
| 55 | + run: | |
| 56 | + npm install -g localtunnel |
| 57 | + host=$(kubectl get svc -n flaskapp | grep flaskapp | tr -s ' ' | cut -d" " -f4) |
| 58 | + port=$(kubectl get svc -n flaskapp | grep flaskapp | tr -s ' ' | cut -d" " -f5 | cut -d":" -f1) |
| 59 | + lt -p $port -l $host -s $SUBDOMAIN |
0 commit comments