|
| 1 | +name: Production Build Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Set most recent tag |
| 15 | + id: vars |
| 16 | + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} |
| 17 | + |
| 18 | + - uses: docker/setup-buildx-action@v3 |
| 19 | + name: Set up Docker Buildx |
| 20 | + |
| 21 | + - uses: docker/login-action@v3 |
| 22 | + name: Login to DockerHub |
| 23 | + with: |
| 24 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 25 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 26 | + |
| 27 | + - uses: docker/build-push-action@v6 |
| 28 | + name: Build and Push WebApp Image |
| 29 | + id: docker_build |
| 30 | + with: |
| 31 | + context: . |
| 32 | + push: true |
| 33 | + tags: orgsinfo/webapp:${{ step.vars.outputs.tag }} |
| 34 | + file: Dockerfile.production |
| 35 | + |
| 36 | + - name: WebApp Image Digest |
| 37 | + run: echo ${{ steps.docker_build.outputs.digest }} |
| 38 | + |
| 39 | + deploy: |
| 40 | + needs: docker |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Set most recent tag |
| 46 | + id: vars |
| 47 | + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} |
| 48 | + |
| 49 | + - name: Deploy the app to the cluster |
| 50 | + uses: nickgronow/kubectl@master |
| 51 | + with: |
| 52 | + config_data: ${{ secrets.KUBE_CONFIG_DATA }} |
| 53 | + args: set image deployment/webapp-production webapp-prod-app=orgsinfo/webapp:${{ steps.vars.outputs.tag }} --namespace=production |
| 54 | + |
| 55 | + - name: Verify deployment |
| 56 | + uses: nickgronow/kubectl@master |
| 57 | + with: |
| 58 | + config_data: ${{ secrets.KUBE_CONFIG_DATA }} |
| 59 | + args: rollout status deployment/webapp-production --namespace=production |
0 commit comments