Promote to Backend Staging #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Promote to Backend Staging | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to promote' | |
required: true | |
jobs: | |
promote: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Pull dev image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./backend | |
push: false | |
tags: sayinmehmet47/backend-kitapkurdu-1:${{ github.event.inputs.version }} | |
load: true | |
- name: Retag image for staging | |
run: docker tag sayinmehmet47/backend-kitapkurdu-1:${{ github.event.inputs.version }} sayinmehmet47/backend-kitapkurdu-1:staging.${{ github.event.inputs.version }} | |
- name: Push staging image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./backend | |
push: true | |
tags: sayinmehmet47/backend-kitapkurdu-1:staging.${{ github.event.inputs.version }} | |
- name: Deploy to Kubernetes | |
run: | | |
kubectl config set-cluster kubernetes --server="https://rancher.riwi.dev/k8s/clusters/c-m-cp898j4l" | |
kubectl config set-credentials github-action --token=${{ secrets.KUBE_CONFIG_TOKEN }} | |
kubectl config set-context default --cluster=kubernetes --user=github-action | |
kubectl config use-context default | |
kubectl set image deployment/backend-deployment-dev kitapkurdu=sayinmehmet47/backend-kitapkurdu-1:staging.${{ github.event.inputs.version }} -n kitapkurdu | |
env: | |
KUBECONFIG: kubeconfig |