aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/main-branch.yml
blob: 4589123df12c2b429e32ed111be5092bb53bcc8f (plain) (blame)
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: Create release and push production server image to dockerhub
on:
  push:
    branches:
      - main
jobs:
  Build-docker-and-push:
    name: Build the production docker container image and push it to dockerhub
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - uses: docker/build-push-action@v5
        with:
          push: true
          context: .
          file: ./docker/prod/Dockerfile
          tags: ${{ secrets.DOCKERHUB_USERNAME }}/pico-web-server:latest

  Release:
    name: Make github release
    runs-on: ubuntu-latest
    needs: Build-docker-and-push
    steps:
      - uses: actions/checkout@v4
      - uses: rymndhng/release-on-push-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
        with:
          bump_version_scheme: norelease # PR must have one of these labels: release:major, release:minor, release:patch

  Deploy-kubernetes:
    name: Deploy kubernetes cluster locally to an action
    runs-on: ubuntu-latest
    needs: Build-docker-and-push
    steps:
      - uses: medyagh/setup-minikube@master
      - name: Pull (release) docker image
        run: |
          docker pull ${{ secrets.DOCKERHUB_USERNAME }}/pico-web-server:latest

      - name: Checkout previous
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - run: git checkout HEAD^
      - name: Minikube deploy
        run: |
          kubectl apply -f kubernetes/
          kubectl rollout status deployment/pico-web-server-deployment
      - name: Minikube use
        run: |
          minikube service list

      - name: Checkout current
        run: git checkout main
      - name: Minikube update
        run: |
          kubectl apply -f kubernetes/
          kubectl rollout status deployment/pico-web-server-deployment
      - name: Minikube use
        run: |
          minikube service list

      - name: Minikube stop
        run: |
          minikube stop