11name : Build and Deploy
22
3- on :
4- workflow_dispatch :
5- inputs :
6- version :
7- description : " Version of the release"
3+ on :
4+ push :
5+ tags :
6+ - ' v*.*.*'
87
98env :
109 DEPLOYMENT : " web"
1716 steps :
1817 - name : Check out the repo
1918 uses : actions/checkout@v3
20-
19+
2120 - name : Log in to Docker Hub
2221 uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2322 with :
2928 uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
3029 with :
3130 images : joinpickup/web
32- tags : latest, ${{ github.event.inputs.version }}
31+ tags : latest, ${{ github.ref_name }}
3332
3433 - name : Build and push Docker image
3534 uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
@@ -41,19 +40,20 @@ jobs:
4140 deploy :
4241 needs : push_to_registry
4342 runs-on : ubuntu-latest
44- steps :
45- - name : checkout master
46- uses : actions/checkout@main
47- - name : install doctl
43+ steps :
44+ - name : Checkout Master
45+ uses : actions/checkout@main
46+ - name : Install Doctl
4847 uses : digitalocean/action-doctl@v2
4948 with :
5049 token : ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
5150
52- - name : save DigitalOcean kubeconfig with short-lived credentials
51+ - name : Save DigitalOcean kubeconfig with short-lived credentials
5352 run : doctl kubernetes cluster kubeconfig save --expiry-seconds 600 $(echo $CLUSTER)
5453
55- - name : deploy to DigitalOcean Kubernetes
56- run : sed -e 's|$TAG|${{ github.event.inputs.version }}|g' $GITHUB_WORKSPACE/iac/deployment.yaml | kubectl apply -f -
54+ - name : Deploy to DigitalOcean Kubernetes
55+ run : sed -e 's|$TAG|${{ github.ref_name }}|g' -e 's|$VERSION|${{ github.ref_name }}|g' $GITHUB_WORKSPACE/iac/deployment.yaml | kubectl apply -f -
5756
58- - name : verify deployment
57+ - name : Verify deployment
5958 run : kubectl -n prod rollout status deployment/$(echo $DEPLOYMENT)
59+
0 commit comments