How do I set up a GitHub Actions workflow to automatically deploy a Docker application #139087
Answered
by
ThienNg0
meobietcode
asked this question in
Actions
-
Select Topic AreaQuestion BodyHow do I set up a GitHub Actions workflow to automatically deploy a Docker application to a Kubernetes cluster, but only when the code changes are pushed to the main branch and have been approved by at least two people in a pull request? |
Beta Was this translation helpful? Give feedback.
Answered by
ThienNg0
Sep 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use a combination of GitHub Actions features to achieve this:
name: Deploy the app
on:
pull_request:
branches:
types: [closed]
jobs:
check-approvals:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && github.event.pull_request.state == 'closed'
steps:
uses: pullreminders/github-action-required-approvals@v1.0
with:
required_approvals: 2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: check-approvals
runs-on: ubuntu-latest
if: ${{ needs.checkout.outputs.approved == 'true' }}
steps:
uses: actions/checkout@v3
Steps to build and push your Docker image
...
use…