|
1 | 1 | name: Production pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: # Allows manual execution |
5 | | - |
6 | | -jobs: |
7 | | - build-and-deploy: |
8 | | - runs-on: ubuntu-latest |
9 | | - steps: |
10 | | - - name: 'Checkout GitHub Action' |
11 | | - uses: actions/checkout@main |
12 | | - |
13 | | - - name: 'Login via Azure CLI' |
14 | | - uses: azure/login@v1 |
15 | | - with: |
16 | | - creds: ${{ secrets.AZURE_CREDENTIALS }} |
17 | | - |
18 | | - - name: 'Set up Kubernetes' |
19 | | - uses: azure/aks-set-context@v2 |
20 | | - with: |
21 | | - creds: ${{ secrets.AZURE_CREDENTIALS }} |
22 | | - cluster-name: ${{ secrets.AKS_CLUSTER_NAME }} |
23 | | - resource-group: ${{ secrets.AKS_RESOURCE_GROUP }} |
24 | | - |
25 | | - - name: 'Build and push image' |
26 | | - uses: azure/docker-login@v1 |
27 | | - with: |
28 | | - login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} |
29 | | - username: ${{ secrets.REGISTRY_USERNAME }} |
30 | | - password: ${{ secrets.REGISTRY_PASSWORD }} |
31 | | - - run: | |
32 | | - if [ ! -f .env ]; then |
33 | | - touch .env |
34 | | - fi |
35 | | - cp swagger.prod .env |
36 | | - docker build -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }} -f ./docker/Dockerfile . |
37 | | - docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:latest |
38 | | -
|
39 | | - docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }} |
40 | | - docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:latest |
41 | | - - name: 'Copy production values files' |
42 | | - run: | |
43 | | - cp ./helm-chart/values-production.yaml ./helm-chart/values.yaml |
44 | | -
|
45 | | - - name: 'Deploy to AKS with Helm' |
46 | | - run: | |
47 | | - helm upgrade --install whatnow ./helm-chart \ |
48 | | - --namespace ${{ secrets.AKS_CLUSTER_NAMESPACE }} \ |
49 | | - --create-namespace |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | + branches: |
| 8 | + - 'staging' |
50 | 9 |
|
51 | 10 |
|
| 11 | +jobs: |
| 12 | + build-and-deploy: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: 'Checkout GitHub Action' |
| 16 | + uses: actions/checkout@main |
| 17 | + |
| 18 | + - name: 'Login via Azure CLI' |
| 19 | + uses: azure/login@v1 |
| 20 | + with: |
| 21 | + creds: ${{ secrets.AZURE_CREDENTIALS }} |
| 22 | + |
| 23 | + - name: 'Set up Kubernetes' |
| 24 | + uses: azure/aks-set-context@v2 |
| 25 | + with: |
| 26 | + creds: ${{ secrets.AZURE_CREDENTIALS }} |
| 27 | + cluster-name: ${{ secrets.AKS_CLUSTER_NAME }} |
| 28 | + resource-group: ${{ secrets.AKS_RESOURCE_GROUP }} |
| 29 | + |
| 30 | + - name: 'Build and push image' |
| 31 | + uses: azure/docker-login@v1 |
| 32 | + with: |
| 33 | + login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} |
| 34 | + username: ${{ secrets.REGISTRY_USERNAME }} |
| 35 | + password: ${{ secrets.REGISTRY_PASSWORD }} |
| 36 | + - run: | |
| 37 | + if [ ! -f .env ]; then |
| 38 | + touch .env |
| 39 | + fi |
| 40 | + cp swagger.prod .env |
| 41 | + docker build -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }} -f ./docker/Dockerfile . |
| 42 | + docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:latest |
| 43 | + docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }} |
| 44 | + docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:latest |
| 45 | +
|
| 46 | + - name: 'Copy staging values file' |
| 47 | + run: | |
| 48 | + cp ./helm-chart/values-production.yaml ./helm-chart/values.yaml |
| 49 | +
|
| 50 | + - name: 'Deploy to AKS with Helm' |
| 51 | + run: | |
| 52 | + helm upgrade --install whatnow-qa ./helm-chart \ |
| 53 | + --namespace ${{ secrets.AKS_CLUSTER_NAMESPACE_QA }} \ |
| 54 | + --create-namespace |
0 commit comments